Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Update prompt in service.py to clarify response for vague queries

mertunsall51d7626c1ae1
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.py
index 9ab5214ad..143e8235e 100644
--- a/browser_use/controller/service.py
+++ b/browser_use/controller/service.py
@@ -408,7 +408,7 @@ Only use this for extracting info from a single product/article page, not for en
+ content[-max_chars // 2 :]
)
- prompt = 'You convert websites into structured information. Extract information from this webpage based on the query. Focus only on content relevant to the query. If the query is vague, does not make sense for the page, provide a brief summary of the page. Respond in JSON format.\nQuery: {query}\n Website:\n{page}'
+ prompt = 'You convert websites into structured information. Extract information from this webpage based on the query. Focus only on content relevant to the query. If the query is vague, does not make sense for the page, or the information is not available, explain the content of the page and state that the information is not available. Respond in JSON format.\nQuery: {query}\n Website:\n{page}'
template = PromptTemplate(input_variables=['query', 'page'], template=prompt)
try:
output = await page_extraction_llm.ainvoke(template.format(query=query, page=content))