{"record":{"id":"1f7c96d586715348","repo":"langchain-ai/deepagents","slug":"workspace-binding-was-not-persisted-for-thread-th","errorCode":null,"errorMessage":"workspace binding was not persisted for thread {thread_id}","messagePattern":"workspace binding was not persisted for thread (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/workspace.py","lineNumber":248,"sourceCode":"            (\n                thread_id,\n                proposed.schema_version,\n                proposed.workspace_id,\n                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,","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/workspace.py#L230-L266","documentation":"In `_bind`, after inserting a proposed workspace binding inside a transaction, the code re-reads the row for `thread_id` from `dcode_thread_workspaces`. This RuntimeError is an internal consistency check: the row must exist after the bind attempt; if it does not, persistence failed unexpectedly.","triggerScenarios":"A concurrent transaction deleted the row between insert/upsert and re-select; a database trigger or migration removed rows; a corrupted or externally modified `dcode_thread_workspaces` table.","commonSituations":"Another process (or a cleanup job) purging thread rows while a bind is in flight; running against a shared SQLite database with manual row deletion; bugs in custom tooling that manipulates the table.","solutions":["Retry the bind operation; this is typically transient","Check for external jobs or tooling deleting rows from `dcode_thread_workspaces`","If reproducible, inspect the database file for corruption and restore/recreate the thread workspaces table"],"exampleFix":"// before\nconn.execute(\"DELETE FROM dcode_thread_workspaces\")  # external cleanup racing binds\n// after\nconn.execute(\"DELETE FROM dcode_thread_workspaces WHERE thread_id IN (SELECT ... expired ...)\")","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    await bind_thread_workspace(tid, cwd)\nexcept RuntimeError as exc:\n    if \"not persisted\" in str(exc):\n        await asyncio.sleep(0.05)\n        await bind_thread_workspace(tid, cwd)","preventionTips":["Avoid external jobs deleting rows from dcode_thread_workspaces during runs","Use single-process access to the binding DB where possible","Retry transient bind failures"],"tags":["workspace","sqlite","persistence","race-condition"],"backgroundTag":"workspace-binding-not-persisted","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}