{"record":{"id":"e169166d98f53b3f","repo":"langchain-ai/deepagents","slug":"thread-not-found-value","errorCode":null,"errorMessage":"Thread not found: {value}","messagePattern":"Thread 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":181,"sourceCode":"\ndef _resolve_thread_id(conn: sqlite3.Connection, value: str) -> str:\n    exact = conn.execute(\n        \"SELECT 1 FROM checkpoints WHERE thread_id = ? AND checkpoint_ns = '' LIMIT 1\",\n        (value,),\n    ).fetchone()\n    if exact:\n        return value\n    escaped = value.replace(\"\\\\\", \"\\\\\\\\\").replace(\"%\", \"\\\\%\").replace(\"_\", \"\\\\_\")\n    rows = conn.execute(\n        \"SELECT DISTINCT thread_id FROM checkpoints \"\n        \"WHERE checkpoint_ns = '' AND thread_id LIKE ? ESCAPE '\\\\' \"\n        \"ORDER BY thread_id LIMIT 11\",\n        (escaped + \"%\",),\n    ).fetchall()\n    matches = [str(row[0]) for row in rows]\n    if not matches:\n        msg = f\"Thread not found: {value}\"\n        raise SystemExit(msg)\n    if len(matches) > 1:\n        rendered = \"\\n\".join(f\"  {match}\" for match in matches[:10])\n        msg = f\"Thread prefix is ambiguous:\\n{rendered}\"\n        raise SystemExit(msg)\n    return matches[0]\n\n\ndef _decode_metadata(\n    value: object, warnings: list[str] | None = None\n) -> dict[str, object]:\n    if isinstance(value, bytes):\n        try:\n            value = value.decode(\"utf-8\")\n        except UnicodeDecodeError:\n            if warnings is not None:\n                warnings.append(\"Checkpoint metadata was not valid UTF-8.\")\n            return {}\n    if not isinstance(value, str) or not value:","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/built_in_skills/deepagents-thread-inspector/scripts/inspect_sessions.py#L163-L199","documentation":"Raised by `_resolve_thread_id` in the thread-inspector CLI when a user-supplied thread ID (or prefix) matches no rows in the checkpointer's `thread_id` lookup (the SQL `LIKE 'value%'` query returns no matches). The script converts it to `SystemExit` with a non-zero status, so it's a controlled CLI failure, not a crash.","triggerScenarios":"Running `inspect_sessions.py <id>` where the ID is a full or partial thread ID that does not exist in the checkpointer database: typo'd ID, wrong DB path, thread from a different project/environment, or a purged/expired thread.","commonSituations":"Copying a thread ID from logs of another environment, pointing --db at the wrong sqlite file, threads deleted by TTL cleanup, or truncating/copying IDs incorrectly (e.g. missing characters).","solutions":["Run `inspect_sessions.py --list N` to enumerate existing thread IDs and pick the correct one","Verify you are pointing at the correct checkpointer/store database (right --db path or runtime environment)","Paste the full, unmodified thread ID rather than a hand-typed prefix","Check whether the thread still exists in LangSmith/backend (it may have been deleted or expired)"],"exampleFix":"// before\ninspect_sessions.py e3a1f9   # typo, no match\n// after\ninspect_sessions.py --list 10  # find the right thread_id first","handlingStrategy":"validation","validationCode":"import subprocess, sys\nresult = subprocess.run(\n    [\"inspect_sessions.py\", \"--list\", \"100\"], capture_output=True, text=True\n)\nknown_ids = {line.strip() for line in result.stdout.splitlines() if line.strip()}\nassert my_thread_id in known_ids, f\"unknown thread: {my_thread_id}\"","typeGuard":"def thread_exists(thread_id: str, known: set[str]) -> bool:\n    return bool(thread_id) and thread_id in known","tryCatchPattern":"try:\n    run_inspector(thread_id)\nexcept SystemExit as e:\n    if \"Thread not found\" in str(e):\n        list_threads_and_retry()\n    else:\n        raise","preventionTips":["Always list threads first when the ID came from memory or another environment","Pass the full untruncated thread ID","Verify the DB path/environment matches where the thread was created"],"tags":["cli","not-found","thread-id"],"backgroundTag":"resource-not-found","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}