langchain-ai/deepagents · error · SystemExit

Use either a thread ID or --list N, not both

Error message

Use either a thread ID or --list N, not both

What it means

`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.

Source

Thrown at libs/code/deepagents_code/built_in_skills/deepagents-thread-inspector/scripts/inspect_sessions.py:614

    Raises:
        SystemExit: If the command-line arguments are invalid, the local session
            store is missing or unsupported, or the Deep Agents Code runtime
            cannot be located.
    """
    args = _build_parser().parse_args()
    if args.max_content < 1:
        msg = "--max-content must be positive"
        raise SystemExit(msg)
    if args.list_limit is not None and args.list_limit < 1:
        msg = "--list must be positive"
        raise SystemExit(msg)
    if args.list_limit is None and not args.thread_id:
        msg = "Provide a thread ID or use --list N"
        raise SystemExit(msg)
    if args.list_limit is not None and args.thread_id:
        msg = "Use either a thread ID or --list N, not both"
        raise SystemExit(msg)

    _ensure_runtime()
    warnings.filterwarnings(
        "ignore",
        message=(
            "Core Pydantic V1 functionality isn't compatible with Python 3.14 "
            "or greater.*"
        ),
    )
    collected_warnings: list[str] = []
    result: dict[str, object]
    conn = _connect_read_only(args.db)
    try:
        if args.list_limit is not None:
            if args.include_metadata or args.mode != "latest-turn":
                collected_warnings.append(
                    "--mode and --include-metadata are ignored when listing threads."
                )

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Remove `--list N` when you have the thread ID you want to inspect
  2. Remove the positional thread ID when you only want to enumerate threads
  3. Fix wrapper scripts that inject `--list` automatically

Example fix

// before
inspect_sessions.py <id> --list 10   # conflicting modes
// after
inspect_sessions.py <id>             # inspect mode only
Defensive patterns

Strategy: validation

Validate before calling

has_thread = bool(argv) and not argv[0].startswith("--")
has_list = "--list" in argv
if has_thread and has_list:
    raise ValueError("pass either a thread ID or --list N, not both")

Type guard

def modes_are_exclusive(argv: list[str]) -> bool:
    has_thread = bool(argv) and not argv[0].startswith("--")
    has_list = any(a == "--list" for a in argv)
    return not (has_thread and has_list)

Try / catch

try:
    run_inspector(*argv)
except SystemExit as e:
    if "not both" in str(e):
        argv = [a for a in argv if a != "--list" and not a.isdigit()]
        run_inspector(*argv)
    else:
        raise

Prevention

When it happens

Trigger: Running e.g. `inspect_sessions.py abc123 --list 10` — both a thread ID and a list limit supplied on the same command line.

Common situations: Shell aliases or wrapper scripts that append `--list` unconditionally; copy-pasting an example command and adding a thread ID on top.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/bba83764d5d23084. Report an issue: GitHub.