{"record":{"id":"54dca49f56a94a72","repo":"langchain-ai/deepagents","slug":"a-thread-id-and-workspace-context-are-required-for","errorCode":null,"errorMessage":"A thread id and workspace context are required for execution.","messagePattern":"A thread id and workspace context are required for execution\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/server_graph.py","lineNumber":634,"sourceCode":"    return await _get_runtime()\n\n\nasync def make_graph(\n    config: dict[str, Any] | None = None,\n    runtime: LangGraphServerRuntime[CLIContextSchema] | None = None,\n) -> Any:  # noqa: ANN401\n    \"\"\"Return the graph after validating execution workspace context.\n\n    Raises:\n        ValueError: If execution context is missing or malformed.\n    \"\"\"\n    execution = runtime.execution_runtime if runtime is not None else None\n    if execution is not None:\n        context = CLIContextSchema.from_payload(execution.context)\n        thread_id = (config or {}).get(\"configurable\", {}).get(\"thread_id\")\n        if context is None or not isinstance(thread_id, str) or not thread_id:\n            msg = \"A thread id and workspace context are required for execution.\"\n            raise ValueError(msg)\n        from deepagents_code.workspace import require_thread_workspace\n\n        binding = await require_thread_workspace(thread_id, context.workspace)\n        return (await _workspace_runtime(binding)).agent\n    return (await get_server_runtime()).agent\n","sourceCodeStart":616,"sourceCodeEnd":640,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/server_graph.py#L616-L640","documentation":"ValueError raised by make_graph when the execution runtime is present but the request lacks the two things needed to run: a workspace context in the execution payload and a non-empty thread_id in config.configurable. Without both, the server cannot resolve the thread's bound workspace.","triggerScenarios":"Invoking the graph with an execution context whose payload yields context=None, or with config missing / containing an empty or non-string configurable.thread_id.","commonSituations":"Calling the agent programmatically without a thread_id; a client that lost its session state; race where context payload was cleared; test harness invoking execution path without proper configurable.","solutions":["Pass a non-empty thread_id: config={\"configurable\": {\"thread_id\": \"<id>\"}}","Ensure the execution context payload includes valid workspace context before invoking","If you intended no workspace execution, invoke without an execution runtime so it uses the default server runtime"],"exampleFix":"// before\nagent = await make_graph({})  # no thread id\n\n// after\nagent = await make_graph({\"configurable\": {\"thread_id\": thread_id}})\n# with execution.context containing workspace info","handlingStrategy":"validation","validationCode":"thread_id = (config or {}).get(\"configurable\", {}).get(\"thread_id\")\nif not isinstance(thread_id, str) or not thread_id:\n    raise ValueError(\"thread_id is required in config.configurable\")\nif execution_context_payload.get(\"workspace\") is None:\n    raise ValueError(\"workspace context is required in execution context\")","typeGuard":"def has_thread_id(config: dict | None) -> TypeGuard[dict]:\n    tid = (config or {}).get(\"configurable\", {}).get(\"thread_id\")\n    return isinstance(tid, str) and bool(tid)","tryCatchPattern":"try:\n    agent = await make_graph(config)\nexcept ValueError as e:\n    if \"thread id\" in str(e):\n        config = {\"configurable\": {\"thread_id\": new_thread_id()}}\n        agent = await make_graph(config)\n    else:\n        raise","preventionTips":["Always generate/persist a thread_id before invoking the execution path","Keep workspace context in the execution payload for every run","Only invoke without thread/workspace when intentionally using the default runtime","Assert configurable.thread_id in integration test harnesses"],"tags":["graph","thread","validation","invocation"],"backgroundTag":"missing-thread-id","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}