{"record":{"id":"bba83764d5d23084","repo":"langchain-ai/deepagents","slug":"use-either-a-thread-id-or-list-n-not-both","errorCode":null,"errorMessage":"Use either a thread ID or --list N, not both","messagePattern":"Use either a thread ID or --list N, not both","errorType":"validation","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/built_in_skills/deepagents-thread-inspector/scripts/inspect_sessions.py","lineNumber":614,"sourceCode":"\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\":\n                collected_warnings.append(\n                    \"--mode and --include-metadata are ignored when listing threads.\"\n                )","sourceCodeStart":596,"sourceCodeEnd":632,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/built_in_skills/deepagents-thread-inspector/scripts/inspect_sessions.py#L596-L632","documentation":"`main()` forbids combining a positional thread ID with `--list N`; the two modes are mutually exclusive (one inspects a thread, one enumerates threads), so passing both exits with this conflict error.","triggerScenarios":"Running e.g. `inspect_sessions.py abc123 --list 10` — both a thread ID and a list limit supplied on the same command line.","commonSituations":"Shell aliases or wrapper scripts that append `--list` unconditionally; copy-pasting an example command and adding a thread ID on top.","solutions":["Remove `--list N` when you have the thread ID you want to inspect","Remove the positional thread ID when you only want to enumerate threads","Fix wrapper scripts that inject `--list` automatically"],"exampleFix":"// before\ninspect_sessions.py <id> --list 10   # conflicting modes\n// after\ninspect_sessions.py <id>             # inspect mode only","handlingStrategy":"validation","validationCode":"has_thread = bool(argv) and not argv[0].startswith(\"--\")\nhas_list = \"--list\" in argv\nif has_thread and has_list:\n    raise ValueError(\"pass either a thread ID or --list N, not both\")","typeGuard":"def modes_are_exclusive(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 not (has_thread and has_list)","tryCatchPattern":"try:\n    run_inspector(*argv)\nexcept SystemExit as e:\n    if \"not both\" in str(e):\n        argv = [a for a in argv if a != \"--list\" and not a.isdigit()]\n        run_inspector(*argv)\n    else:\n        raise","preventionTips":["Build command lines programmatically so modes are mutually exclusive","Avoid aliases that append --list unconditionally","Validate argument combinations in wrapper scripts"],"tags":["cli","argument-conflict","usage"],"backgroundTag":"conflicting-arguments","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}