Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Update system prompt and service for task completion handling
Magnus Müller88f018ad817c
diff --git a/browser_use/agent/system_prompt.md b/browser_use/agent/system_prompt.mdindex 4d9b321c9..765060492 100644--- a/browser_use/agent/system_prompt.md+++ b/browser_use/agent/system_prompt.md@@ -49,7 +49,7 @@ Common action sequences:5. TASK COMPLETION:- Use the done action as the last action as soon as the ultimate task is complete- Dont use "done" before you are done with everything the user asked you, except you reach the last step of max_steps.-- If you reach the max_steps, use the done action even you are not finished and provide all the information you have gathered so far.+- If you reach the max_steps, use the done action even you are not finished and provide all the information you have gathered so far. If the task is not finished set success to false.- If you have to do something repeatedly for example the task says for "each", or "for all", or "x times", count always inside "memory" how many times you have done it and how many remain. Don't stop until you have completed like the task asked you. Only call done after the last step.- Don't hallucinate actions- Make sure to include everything the user asked for in the done text parameter. This is what the user will see. Do not just say you are done, but include the requested information of the task.diff --git a/browser_use/controller/service.py b/browser_use/controller/service.pyindex de560c9bc..ec4419324 100644--- a/browser_use/controller/service.py+++ b/browser_use/controller/service.py@@ -47,14 +47,20 @@ class Controller(Generic[Context]):class ExtendedOutputModel(output_model): # type: ignoresuccess: bool = True- @self.registry.action('Complete task', param_model=ExtendedOutputModel)+ @self.registry.action(+ 'Complete task - with return text and if the ultimate task is reached (success=True) or (success=False)',+ param_model=ExtendedOutputModel,+ )async def done(params: ExtendedOutputModel):# Exclude success from the output JSON since it's an internal parameteroutput_dict = params.model_dump(exclude={'success'})return ActionResult(is_done=True, success=params.success, extracted_content=json.dumps(output_dict))else:- @self.registry.action('Complete task', param_model=DoneAction)+ @self.registry.action(+ 'Complete task - with return text and if the ultimate task is reached (success=True) or (success=False)',+ param_model=DoneAction,+ )async def done(params: DoneAction):return ActionResult(is_done=True, success=params.success, extracted_content=params.text)