langchain-ai/deepagents · error · SystemExit

--max-content must be positive

Error message

--max-content must be positive

What it means

Argument validation in `main()` of the thread-inspector CLI: `--max-content` (the per-message content truncation limit) must be >= 1; zero or negative values would produce empty output, so the script exits immediately.

Source

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

        "--include-metadata",
        action="store_true",
        help="Include latest checkpoint metadata",
    )
    return parser


def main() -> None:
    """Parse arguments, inspect the session store, and write JSON to stdout.

    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.*"
        ),
    )

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Pass a positive integer, e.g. `--max-content 2000`
  2. Omit the flag to use the default limit
  3. Fix the script/variable supplying the value so it computes a value >= 1

Example fix

// before
inspect_sessions.py <id> --max-content 0
// after
inspect_sessions.py <id> --max-content 4000
Defensive patterns

Strategy: validation

Validate before calling

max_content = int(os.environ.get("MAX_CONTENT", 2000))
if max_content < 1:
    raise ValueError("--max-content must be >= 1")

Type guard

def is_positive_int(v: object) -> bool:
    return isinstance(v, int) and not isinstance(v, bool) and v >= 1

Try / catch

try:
    run_inspector(thread_id, max_content=n)
except SystemExit as e:
    if "--max-content must be positive" in str(e):
        run_inspector(thread_id, max_content=2000)
    else:
        raise

Prevention

When it happens

Trigger: Invoking `inspect_sessions.py <thread> --max-content 0` or a negative number such as `--max-content -100`.

Common situations: Attempting to 'disable' content by passing 0, scripted invocations with a computed limit that evaluated to <= 0, or misreading the flag's units.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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