{"record":{"id":"2212db811b65dcfc","repo":"langchain-ai/deepagents","slug":"thread-thread-id-is-already-bound-to-a-different","errorCode":null,"errorMessage":"thread {thread_id} is already bound to a different workspace","messagePattern":"thread (.+?) is already bound to a different workspace","errorType":"exception","errorClass":"WorkspaceConflictError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/workspace.py","lineNumber":252,"sourceCode":"                proposed.cwd,\n                proposed.project_root,\n                proposed.generation,\n                proposed.resource_key,\n                proposed.config_fingerprint,\n                proposed.workspace_config_json,\n            ),\n        )\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\"workspace binding was not persisted for thread {thread_id}\"\n            raise RuntimeError(msg)\n        existing = _row_binding(row)\n        if _binding_differs(existing, proposed):\n            msg = f\"thread {thread_id} is already bound to a different workspace\"\n            raise WorkspaceConflictError(msg)\n        if not existing.config_fingerprint:\n            conn.execute(\n                \"\"\"\n                UPDATE dcode_thread_workspaces\n                SET schema_version = ?, resource_key = ?, config_fingerprint = ?,\n                    workspace_config_json = ?\n                WHERE thread_id = ? AND config_fingerprint = ''\n                \"\"\",\n                (\n                    proposed.schema_version,\n                    proposed.resource_key,\n                    proposed.config_fingerprint,\n                    proposed.workspace_config_json,\n                    thread_id,\n                ),\n            )\n            return proposed\n        return existing","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/workspace.py#L234-L270","documentation":"`_bind` detects that the thread already has a persisted workspace binding and compares it with the proposed one. This `WorkspaceConflictError` is raised when the existing binding differs (different resource key, cwd/fingerprint, or config fingerprint), i.e. the same thread is being re-bound to a different workspace.","triggerScenarios":"Calling `bind_thread_workspace` for a thread_id already bound, with a different `cwd`, `workspace_config`, or `config_fingerprint`; resuming a session from a moved directory; changing workspace_config between runs of the same thread.","commonSituations":"Renaming or moving the project directory and re-running the same thread id; editing the workspace config after the first bind; reusing a persisted thread id from a checkpoint in a different checkout; config_fingerprint mismatch after config normalization changed.","solutions":["Use the workspace the thread was originally bound to (cd back to the original cwd, restore the original config)","Start a new thread for the different workspace instead of rebinding","If the new binding is intentional, clear/rebind via the library's supported reset path or delete the row and rebind"],"exampleFix":"// before\nbind_thread_workspace(thread_id=tid, cwd=\"/projects/renamed\")  # conflict\n// after\nbind_thread_workspace(thread_id=tid, cwd=\"/projects/original\")  # or new thread id","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    await bind_thread_workspace(tid, cwd, workspace_config=cfg)\nexcept WorkspaceConflictError:\n    logging.warning(\"thread %s already bound elsewhere; starting new thread\", tid)\n    tid = new_thread_id()\n    await bind_thread_workspace(tid, cwd, workspace_config=cfg)","preventionTips":["Keep the same cwd and config for the lifetime of a thread","Use a new thread id whenever workspace changes","Resolve symlinks consistently before binding"],"tags":["workspace","conflict","binding","thread"],"backgroundTag":"workspace-binding-conflict","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}