{"record":{"id":"88d8944d24a3826c","repo":"langchain-ai/deepagents","slug":"sessions-database-not-found-resolved","errorCode":null,"errorMessage":"Sessions database not found: {resolved}","messagePattern":"Sessions database not found: (.+?)","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/built_in_skills/deepagents-thread-inspector/scripts/inspect_sessions.py","lineNumber":146,"sourceCode":"            home = Path.home() / configured[2:].lstrip(\"/\")\n        elif configured.startswith(\"~\") or not Path(configured).is_absolute():\n            msg = (\n                f\"Invalid DEEPAGENTS_HOME {configured!r}: use an absolute path \"\n                \"or a path beginning with '~/'.\"\n            )\n            raise SystemExit(msg) from None\n        else:\n            home = Path(configured)\n    else:\n        home = get_deepagents_home()\n    return home / \".state\" / \"sessions.db\"\n\n\ndef _connect_read_only(path: Path) -> sqlite3.Connection:\n    resolved = path.expanduser().resolve()\n    if not resolved.is_file():\n        msg = f\"Sessions database not found: {resolved}\"\n        raise SystemExit(msg)\n    conn = sqlite3.connect(f\"{resolved.as_uri()}?mode=ro\", uri=True)\n    conn.row_factory = sqlite3.Row\n    tables = {\n        row[0]\n        for row in conn.execute(\n            \"SELECT name FROM sqlite_master WHERE type = 'table'\"\n        ).fetchall()\n    }\n    missing = {\"checkpoints\", \"writes\"} - tables\n    if missing:\n        conn.close()\n        names = \", \".join(sorted(missing))\n        msg = f\"Not a supported sessions database; missing tables: {names}\"\n        raise SystemExit(msg)\n    return conn\n\n\ndef _resolve_thread_id(conn: sqlite3.Connection, value: str) -> str:","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/built_in_skills/deepagents-thread-inspector/scripts/inspect_sessions.py#L128-L164","documentation":"Before querying, `_connect_read_only` resolves the sessions DB path (expanduser + resolve) and verifies it exists as a regular file; if not, the script exits with this SystemExit message showing the resolved path. This means there is no sessions database at the expected location — the inspector cannot open anything in read-only SQLite mode.","triggerScenarios":"Running inspect_sessions.py with `--db` pointing to a non-existent file, or with the default path derived from `DEEPAGENTS_HOME`/`get_deepagents_home()` where no session has ever been recorded (missing `~/.deepagents/.state/sessions.db`).","commonSituations":"Wrong `DEEPAGENTS_HOME` pointing at a fresh/empty directory; inspecting sessions from a different machine or user; typo in `--db`; running before ever launching dcode so no DB was created.","solutions":["Verify the resolved path in the message exists (`ls <resolved>`); if not, locate the real DB (default `~/.deepagents/.state/sessions.db`).","Set `DEEPAGENTS_HOME` to the directory that actually contains `.state/sessions.db`, or pass `--db /path/to/sessions.db`.","Run dcode at least once to create the database before inspecting.","Check you are on the machine/user account where the sessions were recorded."],"exampleFix":"// before\n$ python inspect_sessions.py --db ./old/sessions.db  # file absent\n// after\n$ python inspect_sessions.py --db ~/.deepagents/.state/sessions.db","handlingStrategy":"validation","validationCode":"from pathlib import Path\nfrom deepagents_code.paths import get_deepagents_home\n# or derive manually\ndb = Path(os.environ.get('DEEPAGENTS_HOME', str(Path.home() / '.deepagents'))) / '.state' / 'sessions.db'\nif not db.expanduser().is_file():\n    raise SystemExit(f'no sessions db at {db}; run dcode first or pass --db')","typeGuard":"def sessions_db_exists(path) -> bool:\n    return path.expanduser().resolve().is_file()","tryCatchPattern":null,"preventionTips":["Check the DB path exists before invoking the inspector; default is ~/.deepagents/.state/sessions.db.","Run dcode at least once on this machine/user before inspecting.","Pass --db explicitly when DEEPAGENTS_HOME is customized.","Back up the sessions DB so it survives cleanups."],"tags":["file-not-found","sqlite","script","configuration"],"backgroundTag":"database-file-not-found","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}