{"record":{"id":"88cf1e4398928110","repo":"langchain-ai/deepagents","slug":"provide-a-thread-id-or-use-list-n","errorCode":null,"errorMessage":"Provide a thread ID or use --list N","messagePattern":"Provide a thread ID or use --list N","errorType":"validation","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/built_in_skills/deepagents-thread-inspector/scripts/inspect_sessions.py","lineNumber":611,"sourceCode":"\ndef main() -> None:\n    \"\"\"Parse arguments, inspect the session store, and write JSON to stdout.\n\n    Raises:\n        SystemExit: If the command-line arguments are invalid, the local session\n            store is missing or unsupported, or the Deep Agents Code runtime\n            cannot be located.\n    \"\"\"\n    args = _build_parser().parse_args()\n    if args.max_content < 1:\n        msg = \"--max-content must be positive\"\n        raise SystemExit(msg)\n    if args.list_limit is not None and args.list_limit < 1:\n        msg = \"--list must be positive\"\n        raise SystemExit(msg)\n    if args.list_limit is None and not args.thread_id:\n        msg = \"Provide a thread ID or use --list N\"\n        raise SystemExit(msg)\n    if args.list_limit is not None and args.thread_id:\n        msg = \"Use either a thread ID or --list N, not both\"\n        raise SystemExit(msg)\n\n    _ensure_runtime()\n    warnings.filterwarnings(\n        \"ignore\",\n        message=(\n            \"Core Pydantic V1 functionality isn't compatible with Python 3.14 \"\n            \"or greater.*\"\n        ),\n    )\n    collected_warnings: list[str] = []\n    result: dict[str, object]\n    conn = _connect_read_only(args.db)\n    try:\n        if args.list_limit is not None:\n            if args.include_metadata or args.mode != \"latest-turn\":","sourceCodeStart":593,"sourceCodeEnd":629,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/built_in_skills/deepagents-thread-inspector/scripts/inspect_sessions.py#L593-L629","documentation":"`main()` requires exactly one mode of operation: either a thread ID to inspect or `--list N` to enumerate threads. With neither provided, the script cannot proceed and exits with this usage error.","triggerScenarios":"Running `inspect_sessions.py` with no positional thread ID and no `--list` flag; also occurs when the thread ID argument is an empty string or was dropped by a wrapper script.","commonSituations":"Forgetting the positional argument, quoting issues dropping an empty argument, or migration from older invocations that defaulted to listing.","solutions":["Provide a thread ID: `inspect_sessions.py <thread-id>`","Or list available threads first: `inspect_sessions.py --list 10`","Run with `--help` to review the required arguments"],"exampleFix":"// before\ninspect_sessions.py            # no thread, no --list\n// after\ninspect_sessions.py --list 10  # discover, then inspect a thread","handlingStrategy":"validation","validationCode":"args = sys.argv[1:]\nhas_thread = bool(args) and not args[0].startswith(\"--\")\nhas_list = \"--list\" in args\nif not has_thread and not has_list:\n    raise ValueError(\"provide a thread ID or --list N\")","typeGuard":"def has_inspection_target(argv: list[str]) -> bool:\n    has_thread = bool(argv) and not argv[0].startswith(\"--\")\n    has_list = any(a == \"--list\" for a in argv)\n    return has_thread != has_list","tryCatchPattern":"try:\n    run_inspector(*argv)\nexcept SystemExit as e:\n    if \"Provide a thread ID\" in str(e):\n        run_inspector(\"--list\", \"10\")\n    else:\n        raise","preventionTips":["Check argv for exactly one mode before invoking","Ensure wrapper scripts don't drop empty positional args","Run --help when unsure of required arguments"],"tags":["cli","missing-argument","usage"],"backgroundTag":"missing-required-argument","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}