{"record":{"id":"fc8c3bc36bc69c56","repo":"microsoft/autogen","slug":"args-is-required-for-type","errorCode":null,"errorMessage":"args is required for {type}","messagePattern":"args is required for (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/tools/mcp/_actor.py","lineNumber":109,"sourceCode":"        return self._initialize_result\n\n    async def initialize(self) -> None:\n        if not self._active:\n            self._active = True\n            self._actor_task = asyncio.create_task(self._run_actor())\n\n    async def call(self, type: str, args: McpActorArgs | None = None) -> McpFuture:\n        if not self._active:\n            raise RuntimeError(\"MCP Actor not running, call initialize() first\")\n        if self._actor_task and self._actor_task.done():\n            raise RuntimeError(\"MCP actor task crashed\", self._actor_task.exception())\n        fut: asyncio.Future[McpFuture] = asyncio.Future()\n        if type in {\"list_tools\", \"list_prompts\", \"list_resources\", \"list_resource_templates\", \"shutdown\"}:\n            await self._command_queue.put({\"type\": type, \"future\": fut})\n            res = await fut\n        elif type in {\"call_tool\", \"read_resource\", \"get_prompt\"}:\n            if args is None:\n                raise ValueError(f\"args is required for {type}\")\n            name = args.get(\"name\", None)\n            kwargs = args.get(\"kargs\", {})\n            if type == \"call_tool\" and name is None:\n                raise ValueError(\"name is required for call_tool\")\n            elif type == \"read_resource\":\n                uri = kwargs.get(\"uri\", None)\n                if uri is None:\n                    raise ValueError(\"uri is required for read_resource\")\n                await self._command_queue.put({\"type\": type, \"uri\": uri, \"future\": fut})\n            elif type == \"get_prompt\":\n                if name is None:\n                    raise ValueError(\"name is required for get_prompt\")\n                prompt_args = kwargs.get(\"arguments\", None)\n                await self._command_queue.put({\"type\": type, \"name\": name, \"args\": prompt_args, \"future\": fut})\n            else:  # call_tool\n                await self._command_queue.put({\"type\": type, \"name\": name, \"args\": kwargs, \"future\": fut})\n            res = await fut\n        else:","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/mcp/_actor.py#L91-L127","documentation":"McpActor.call() dispatches per command type; for 'call_tool', 'read_resource' and 'get_prompt' it must extract name/kwargs from an args dict. If args is None for one of these, ValueError('args is required for {type}') is raised. This is an internal API contract error — callers must pass a dict with at least 'name' (and 'kargs' for parameters).","triggerScenarios":"Calling actor.call('call_tool') / actor.call('read_resource') / actor.call('get_prompt') with args omitted or explicitly None. List-style commands (list_tools etc.) do not need args and are unaffected.","commonSituations":"Writing a thin wrapper around the actor and forwarding an empty call; passing a positional string instead of a dict; forgetting the args dict when migrating code from a client API that took name as a separate parameter.","solutions":["Pass a dict: await actor.call('call_tool', args={'name': 'search', 'kargs': {'query': 'x'}}).","For read_resource use args={'kargs': {'uri': 'file://...'}}; for get_prompt use args={'name': 'prompt_id', 'kargs': {'arguments': {...}}}.","Prefer the higher-level session/workbench APIs which build these dicts for you."],"exampleFix":"# before\nresult = await actor.call(\"call_tool\")\n\n# after\nresult = await actor.call(\"call_tool\", args={\"name\": \"search\", \"kargs\": {\"query\": \"hello\"}})","handlingStrategy":"validation","validationCode":"NEEDS_ARGS = {\"call_tool\", \"read_resource\", \"get_prompt\"}\nif cmd in NEEDS_ARGS and not isinstance(args, dict):\n    raise ValueError(f\"args dict required for {cmd}\")","typeGuard":"from typing import Any, TypeGuard\n\ndef is_actor_args(value: Any) -> TypeGuard[dict]:\n    return isinstance(value, dict)","tryCatchPattern":null,"preventionTips":["Wrap the actor in a typed client class that builds the args dict for callers.","Keep a table of command -> required args and assert against it in tests.","Prefer higher-level session/workbench APIs over raw actor.call."],"tags":["mcp","internal-api","validation","arguments"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}