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
strip success from JSON schema so invisible to the LLM, avoiding confusion
Laith Weinberger04da1fd30c8a
diff --git a/browser_use/tools/service.py b/browser_use/tools/service.pyindex 0ea19e270..3e9a48b05 100644--- a/browser_use/tools/service.py+++ b/browser_use/tools/service.py@@ -2023,7 +2023,7 @@ Validated Code (after quote fixing):param_model=StructuredOutputAction[output_model],)async def done(params: StructuredOutputAction):- # Exclude success from the output JSON since it's an internal parameter+ # Exclude success from the output JSON# Use mode='json' to properly serialize enums at all nesting levelsoutput_dict = params.data.model_dump(mode='json')diff --git a/browser_use/tools/views.py b/browser_use/tools/views.pyindex 5e8d58db3..27c4ada6e 100644--- a/browser_use/tools/views.py+++ b/browser_use/tools/views.py@@ -87,7 +87,14 @@ class DoneAction(BaseModel):T = TypeVar('T', bound=BaseModel)+def _hide_success_from_schema(schema: dict) -> None:+ """Remove 'success' from the JSON schema to avoid field name collisions with user models."""+ schema.get('properties', {}).pop('success', None)++class StructuredOutputAction(BaseModel, Generic[T]):+ model_config = ConfigDict(json_schema_extra=_hide_success_from_schema)+success: bool = Field(default=True, description='True if user_request completed successfully')data: T = Field(description='The actual output data matching the requested schema')