{"record":{"id":"f3a2f3290b5d336f","repo":"langchain-ai/deepagents","slug":"failed-to-get-run-status-e","errorCode":null,"errorMessage":"Failed to get run status: {e}","messagePattern":"Failed to get run status: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/middleware/async_subagents.py","lineNumber":423,"sourceCode":"\n\ndef _build_check_tool(  # noqa: C901  # complexity from necessary error handling\n    clients: _ClientCache,\n) -> StructuredTool:\n    \"\"\"Build the `check_async_task` tool.\"\"\"\n\n    def check_async_task(\n        task_id: str,\n        runtime: ToolRuntime,\n    ) -> str | Command:\n        task = _resolve_tracked_task(task_id, runtime)\n        if isinstance(task, str):\n            return task\n\n        try:\n            client = clients.get_sync(task[\"agent_name\"])\n            run = client.runs.get(thread_id=task[\"thread_id\"], run_id=task[\"run_id\"])\n        except Exception as e:  # noqa: BLE001  # get_sync() may raise ValueError; SDK raises untyped errors\n            return f\"Failed to get run status: {e}\"\n\n        thread_values: dict[str, Any] = {}\n        if run[\"status\"] == \"success\":\n            try:\n                thread = client.threads.get(thread_id=task[\"thread_id\"])\n                thread_values = thread.get(\"values\") or {}\n            except Exception as e:  # noqa: BLE001  # LangGraph SDK raises untyped errors\n                logger.warning(\"Failed to fetch thread values for task %s: %s\", task[\"task_id\"], e)\n\n        result = _build_check_result(run, task[\"thread_id\"], thread_values)\n        return _build_check_command(result, task, runtime.tool_call_id)\n\n    async def acheck_async_task(\n        task_id: str,\n        runtime: ToolRuntime,\n    ) -> str | Command:\n        task = _resolve_tracked_task(task_id, runtime)","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/middleware/async_subagents.py#L405-L441","documentation":"check_async_task wraps client creation and the runs.get status call in a broad except and returns this message string instead of raising, so the calling agent sees a friendly failure. Any error from get_sync (e.g. missing url) or from the LangGraph SDK while fetching run status surfaces as this text.","triggerScenarios":"Polling an async task whose subagent has no url (get_sync ValueError); network/auth failure or invalid thread_id/run_id when calling client.runs.get; SDK raising untyped errors.","commonSituations":"Subagent server restarted or unreachable mid-run; task record references a thread/run that was deleted; spec misconfiguration (url=None) discovered lazily at poll time.","solutions":["Check the subagent 'url' is set and the server is reachable","Read the embedded exception in the returned message and fix the underlying cause (auth, network, IDs)","Use async invocation paths that support ASGI transport when subagents have no url"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if subagent_spec.get(\"url\") is None:\n    # avoid sync status path for ASGI subagents\n    use_async_status_check = True","typeGuard":null,"tryCatchPattern":"try:\n    client = clients.get_sync(task[\"agent_name\"])\n    run = client.runs.get(thread_id=task[\"thread_id\"], run_id=task[\"run_id\"])\nexcept Exception as e:\n    logger.warning(\"run status fetch failed: %s\", e)\n    return None","preventionTips":["Keep the subagent server reachable and monitored","Validate thread_id/run_id before polling","Treat returned failure strings as signals to check connectivity/auth"],"tags":["python","langgraph","network","error-handling"],"backgroundTag":"run-status-fetch-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}