{"record":{"id":"f2c417c61d12e5ed","repo":"FoundationAgents/OpenManus","slug":"parameters-cannot-be-empty","errorCode":null,"errorMessage":"Parameters cannot be empty","messagePattern":"Parameters cannot be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"app/tool/browser_use_tool.py","lineNumber":138,"sourceCode":"            \"extract_content\": [\"goal\"],\n        },\n    }\n\n    lock: asyncio.Lock = Field(default_factory=asyncio.Lock)\n    browser: Optional[BrowserUseBrowser] = Field(default=None, exclude=True)\n    context: Optional[BrowserContext] = Field(default=None, exclude=True)\n    dom_service: Optional[DomService] = Field(default=None, exclude=True)\n    web_search_tool: WebSearch = Field(default_factory=WebSearch, exclude=True)\n\n    # Context for generic functionality\n    tool_context: Optional[Context] = Field(default=None, exclude=True)\n\n    llm: Optional[LLM] = Field(default_factory=LLM)\n\n    @field_validator(\"parameters\", mode=\"before\")\n    def validate_parameters(cls, v: dict, info: ValidationInfo) -> dict:\n        if not v:\n            raise ValueError(\"Parameters cannot be empty\")\n        return v\n\n    async def _ensure_browser_initialized(self) -> BrowserContext:\n        \"\"\"Ensure browser and context are initialized.\"\"\"\n        if self.browser is None:\n            browser_config_kwargs = {\"headless\": False, \"disable_security\": True}\n\n            if config.browser_config:\n                from browser_use.browser.browser import ProxySettings\n\n                # handle proxy settings.\n                if config.browser_config.proxy and config.browser_config.proxy.server:\n                    browser_config_kwargs[\"proxy\"] = ProxySettings(\n                        server=config.browser_config.proxy.server,\n                        username=config.browser_config.proxy.username,\n                        password=config.browser_config.proxy.password,\n                    )\n","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/FoundationAgents/OpenManus/blob/52a13f2a57d8c7f6737eefb02ccf569594d44273/app/tool/browser_use_tool.py#L120-L156","documentation":"Pydantic field_validator (mode='before') on BrowserUseTool.parameters rejects empty input: constructing or validating the tool with parameters={} or parameters=None raises ValueError('Parameters cannot be empty'). The parameters field carries the browser-use action instruction (e.g. {'action': 'go_to_url', 'url': ...}), and an empty value is meaningless, so validation fails at model time, before any browser work starts.","triggerScenarios":"Building BrowserUseTool via pydantic validation with an omitted/empty parameters dict — typically an LLM emitting a tool call with no arguments, or code instantiating the tool to inspect its schema (model_validate on default empty dict).","commonSituations":"Agent framework parses an LLM tool call whose arguments JSON was empty ({}); tests instantiating the tool without arguments; schema-registration code that validates a default instance.","solutions":["Always supply the required action dict: parameters={'action': 'open_tab', 'url': 'https://example.com'} (fields per the browser-use ActionModel).","If the LLM can emit empty tool calls, validate and reject upstream (check the parsed arguments are non-empty) and re-prompt instead of letting pydantic raise.","Catch pydantic's ValidationError at the dispatch layer and map it to a user-facing 'missing browser action parameters' message."],"exampleFix":"# before\nresult = await browser_tool.execute(action=None, parameters={})\n\n# after\nparams = {\"action\": \"go_to_url\", \"url\": \"https://example.com\"}\nresult = await browser_tool.execute(action=\"\", parameters=params)","handlingStrategy":"validation","validationCode":"params = tool_call.get('parameters') or {}\nif not params or 'action' not in params:\n    raise ValueError('browser tool call needs parameters.action')\nresult = await browser_tool.execute(action=tool_call.get('action', ''), parameters=params)","typeGuard":"from pydantic import ValidationError\n\ndef is_valid_browser_params(v: object) -> bool:\n    if not isinstance(v, dict) or not v:\n        return False\n    return isinstance(v.get('action'), str) and bool(v['action'])","tryCatchPattern":"try:\n    result = await browser_tool.execute(action=a, parameters=params)\nexcept ValidationError as e:\n    if 'Parameters cannot be empty' in str(e):\n        return 'error: browser action requires parameters (e.g. {\"action\": \"go_to_url\", \"url\": ...})'\n    raise","preventionTips":["Validate LLM tool-call arguments are non-empty before model validation.","Include a schema example in the tool description so the model emits the action dict.","Map ValidationError to a re-prompt, not a crash."],"tags":["pydantic","browser-use","validation","llm-tool-call"],"backgroundTag":null,"analyzedSha":"52a13f2a57d8c7f6737eefb02ccf569594d44273","analyzedAt":"2026-08-15T02:33:49.993Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}