{"record":{"id":"c926229e2f5c6939","repo":"langchain-ai/deepagents","slug":"workspace-context-does-not-match-thread-thread-id","errorCode":null,"errorMessage":"workspace context does not match thread {thread_id}","messagePattern":"workspace context does not match thread (.+?)","errorType":"exception","errorClass":"WorkspaceConflictError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/workspace.py","lineNumber":363,"sourceCode":"        _, 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)\n            expected = existing.to_payload()\n            if any(data.get(key) != value for key, value in expected.items()):\n                msg = f\"workspace context does not match thread {thread_id}\"\n                raise WorkspaceConflictError(msg)\n            if (\n                claimed_fingerprint is not None\n                and claimed_fingerprint != existing.config_fingerprint\n            ):\n                msg = f\"workspace configuration does not match thread {thread_id}\"\n                raise WorkspaceConflictError(msg)\n            return existing\n\n    existing = await asyncio.to_thread(_require)\n    if existing.schema_version != _SCHEMA_VERSION:\n        msg = f\"workspace binding schema is unsupported for thread {thread_id}\"\n        raise WorkspaceConflictError(msg)\n    resolved = await asyncio.to_thread(\n        resolve_workspace,\n        existing.cwd,\n        existing.workspace_config(),\n        config_fingerprint=existing.config_fingerprint,\n    )","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/workspace.py#L345-L381","documentation":"`require_thread_workspace._require` compares each key in the persisted binding's payload with the claimed context data. This `WorkspaceConflictError` is raised when any field of the provided workspace context (e.g. resource key, cwd, policy) does not equal the persisted binding, meaning the run claims a different workspace than the thread is bound to.","triggerScenarios":"Running a thread from a different working directory than at bind time; a workspace context payload built from a different `resolve_workspace` result; tampered or stale context forwarded from another session.","commonSituations":"Launching the agent from a different shell cwd (or a symlinked path that canonicalizes differently); copying run payloads between threads; upgrading machines where absolute paths changed.","solutions":["Run from the same working directory the thread was bound in (or pass the original cwd)","Regenerate the context from the thread's persisted binding and send it unchanged","If the move is intentional, rebind under a new thread id"],"exampleFix":"// before\nrequire_thread_workspace(tid, payload={**ctx, \"cwd\": \"/elsewhere\"})\n// after\nrequire_thread_workspace(tid, payload=ctx)  # ctx from binding.to_payload()","handlingStrategy":"validation","validationCode":"# regenerate context from the persisted binding instead of stale copies\nbinding = await require_thread_workspace(thread_id, payload=None) if False else None\nctx = binding.to_payload()  # always source context from the binding","typeGuard":null,"tryCatchPattern":"try:\n    await require_thread_workspace(tid, payload=ctx)\nexcept WorkspaceConflictError as exc:\n    if \"does not match\" in str(exc):\n        os.chdir(ctx[\"cwd\"])  # or restart from the bound cwd\n        await require_thread_workspace(tid, payload=ctx)","preventionTips":["Launch runs from the same cwd used at bind time","Never copy contexts between threads","Canonicalize paths (resolve symlinks) before comparing"],"tags":["workspace","conflict","context-mismatch","thread"],"backgroundTag":"workspace-context-mismatch","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}