{"record":{"id":"342d88b7f95d34e1","repo":"crewAIInc/crewAI","slug":"multion-client-is-not-initialized","errorCode":null,"errorMessage":"Multion client is not initialized.","messagePattern":"Multion client is not initialized\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/multion_tool/multion_tool.py","lineNumber":69,"sourceCode":"        self.session_id = None\n        self.multion = MultiOn(api_key=api_key or os.getenv(\"MULTION_API_KEY\"))\n\n    def _run(\n        self,\n        cmd: str,\n        *args: Any,\n        **kwargs: Any,\n    ) -> str:\n        \"\"\"Run the Multion client with the given command.\n\n        Args:\n            cmd (str): The detailed and specific natural language instructrion for web browsing\n\n            *args (Any): Additional arguments to pass to the Multion client\n            **kwargs (Any): Additional keyword arguments to pass to the Multion client\n        \"\"\"\n        if self.multion is None:\n            raise ValueError(\"Multion client is not initialized.\")\n\n        browse = self.multion.browse(\n            cmd=cmd,\n            session_id=self.session_id,\n            local=self.local,\n            max_steps=self.max_steps,\n            *args,  # noqa: B026\n            **kwargs,\n        )\n        self.session_id = browse.session_id\n\n        return str(browse.message) + \"\\n\\n STATUS: \" + str(browse.status)\n","sourceCodeStart":51,"sourceCodeEnd":82,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/multion_tool/multion_tool.py#L51-L82","documentation":"MultiOnTool._run guards against a None self.multion before calling self.multion.browse(...). Under normal construction the client is always created in __init__, so this ValueError mostly appears when the attribute was explicitly set to None, the object was built via model_construct-style paths skipping __init__, or serialization/deserialization lost the client.","triggerScenarios":"Setting tool.multion = None manually; creating the pydantic model without running __init__ (model_construct / dict round-trip); pickling/deep-copying the tool so the client reference is dropped; a failed constructor path that leaves multion unset.","commonSituations":"Passing tools between processes (Celery, multiprocessing) where the non-picklable client becomes None; rebuilding tools from cached config; test fixtures constructing the model directly.","solutions":["Re-instantiate MultiOnTool() instead of reconstructing/deserializing it","After any serialization round-trip, reattach: tool.multion = MultiOn(api_key=os.getenv('MULTION_API_KEY'))","In distributed workers, construct the tool inside the worker process, not in the parent"],"exampleFix":"# before\nimport pickle\ntool = pickle.loads(pickle.dumps(MultiOnTool()))  # client lost\ntool._run(cmd=\"open example.com\")  # ValueError\n\n# after\ndef make_tool():\n    return MultiOnTool()  # construct in the worker process\n# worker:\ntool = make_tool()\ntool._run(cmd=\"open example.com\")","handlingStrategy":"validation","validationCode":"def multion_client_ready(tool) -> bool:\n    return getattr(tool, \"multion\", None) is not None","typeGuard":null,"tryCatchPattern":"try:\n    out = tool._run(cmd=\"open example.com\")\nexcept ValueError as e:\n    if \"not initialized\" in str(e):\n        from multion.client import MultiOn\n        import os\n        tool.multion = MultiOn(api_key=os.getenv(\"MULTION_API_KEY\"))\n        out = tool._run(cmd=\"open example.com\")\n    else:\n        raise","preventionTips":["Construct MultiOnTool inside the worker process, never pickle it","After deserialization, reattach a fresh MultiOn client","Health-check tool clients before starting a crew run"],"tags":["multion","initialization","serialization","crewai-tools"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}