Skip to content

--limit N does not bound the enhance phase, causing large unexpected spend #213

Description

@NahumKorda

Summary

scan --limit 2 runs the agentic enhance phase across the entire dataset before analyzing 2 units. Intended as a cheap smoke test on a real repository, it was on track to cost roughly a tenth of a full scan and was killed partway through.

Evidence

The flag is declared as:

scan_p.add_argument("--limit", type=int, help="Max units to analyze")   # openant/cli.py:1315

core/scanner.py:475 documents the intent for a neighbouring phase — "--limit governs the analyze stage, not how many units the LLM reachability pass reviews — it must see the full codebase to find missed entry points" — and enhance behaves the same way. The help text says only "Max units to analyze," which reads as bounding the run.

Observed: --limit 2 produced [Enhance] Units to enhance: 1351.

Why it matters

Combined with the documented absence of a spend ceiling, the most natural way to try OpenAnt cheaply against a real codebase is also the one that incurs near-full cost. There is no warning, and the phase that runs unbounded is a high-volume per-unit LLM phase.

Suggested fix

Either have --limit bound enhance as well, or add a separate --enhance-limit, and amend the help text to state explicitly that enhance always processes the full dataset. Enhance checkpointing already works correctly, so a bounded enhance costs nothing in resumability.


Observed on one full-pipeline run at production scale: a private TypeScript monorepo (Angular front end, NestJS back end), 1,351 analysis units from 866 source files, run with --verify and no --limit, ~6.5 hours wall clock. The engine was invoked directly (python -m openant scan …, Python 3.13); the Go CLI was not built, so none of this involves the Go↔Python envelope. Stage 1 detection and Stage 2 verification ran on Claude Opus 5; application context, enhancement and reporting on Claude Sonnet 5 — all seven phases routed through OpenRouter (anthropic/claude-opus-5, anthropic/claude-sonnet-5) via a locally-added openrouter provider adapter, on a build based on upstream 2ed78f6. Cost figures are expressed as proportions of the run total; absolute amounts are omitted deliberately, as is the identity of the scanned repository.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions