{"record":{"id":"59fa43021b165759","repo":"langchain-ai/deepagents","slug":"workspace-context-is-required","errorCode":null,"errorMessage":"workspace context is required","messagePattern":"workspace context is required","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/workspace.py","lineNumber":341,"sourceCode":"async def require_thread_workspace(\n    thread_id: str,\n    payload: object,\n    workspace_config: object | None = None,\n    *,\n    config_fingerprint: str | None = None,\n) -> WorkspaceBinding:\n    \"\"\"Validate run context against the durable workspace binding.\n\n    Returns:\n        The server-authoritative binding and persisted resource policy.\n\n    Raises:\n        TypeError: If workspace context is not an object.\n        WorkspaceConflictError: If the context, policy, or workspace has changed.\n    \"\"\"\n    if not isinstance(payload, dict) or not payload:\n        msg = \"workspace context is required\"\n        raise TypeError(msg)\n    data = cast(\"dict[str, Any]\", payload)\n    claimed_fingerprint = config_fingerprint\n    if workspace_config is not None:\n        _, claimed_fingerprint = canonical_workspace_config(workspace_config)\n\n    def _require() -> WorkspaceBinding:\n        with sqlite3.connect(_database_path(), timeout=5) as conn:\n            conn.row_factory = sqlite3.Row\n            conn.execute(\"BEGIN IMMEDIATE\")\n            _initialize(conn)\n            row = conn.execute(\n                \"SELECT * FROM dcode_thread_workspaces WHERE thread_id = ?\",\n                (thread_id,),\n            ).fetchone()\n            if row is None:\n                msg = f\"thread {thread_id} has no workspace binding\"\n                raise WorkspaceConflictError(msg)\n            existing = _row_binding(row)","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/workspace.py#L323-L359","documentation":"`require_thread_workspace` validates the workspace context payload carried with each run. This TypeError is raised when the payload is not a non-empty dict, meaning the run did not carry the workspace context required to verify the thread's binding.","triggerScenarios":"Calling `require_thread_workspace` with `payload=None`, an empty dict `{}`, or a non-dict (list/string); a caller (e.g. `_execute_offload` or `make_graph`) invoking runs without attaching the workspace context produced at bind time.","commonSituations":"Older checkpoints/sessions created before workspace context was introduced; hand-constructed run payloads omitting the context; context dropped when forwarding run metadata through custom middleware.","solutions":["Pass the workspace context payload obtained from the thread's binding (e.g. via `workspace`/`resolve_workspace`) as a non-empty dict","Re-bind the thread to regenerate a context for old sessions","Check the code path that builds run payloads so it always includes the workspace context"],"exampleFix":"// before\nrequire_thread_workspace(thread_id, payload=None)\n// after\nrequire_thread_workspace(thread_id, payload=binding.to_payload())","handlingStrategy":"type-guard","validationCode":"if not isinstance(payload, dict) or not payload:\n    raise TypeError(\"run payload must include a non-empty workspace context\")","typeGuard":"def has_workspace_context(v: object) -> TypeGuard[dict[str, Any]]:\n    return isinstance(v, dict) and len(v) > 0","tryCatchPattern":"try:\n    await require_thread_workspace(tid, payload=ctx)\nexcept TypeError:\n    binding = await bind_thread_workspace(tid, cwd)\n    await require_thread_workspace(tid, payload=binding.to_payload())","preventionTips":["Always attach the context from binding.to_payload() to runs","Re-bind legacy sessions that predate workspace context","Don't hand-construct run payloads"],"tags":["workspace","type-error","context","validation"],"backgroundTag":"missing-workspace-context","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}