Skip to content

fix(cli): plan's next line must not raise a cap the spec already set #1219

Closed

Description

@HugoXK

Problem

plan's next: line adds --max-calls N with N = the structural upper bound, even when the spec already declares its own evolve.max_calls. An explicit flag is sharper than a spec knob (runstore.py:1021-1024: "Wins over a spec's own knobs: an explicit run option is the sharper instruction"), so following plan's own advice silently raises the user's declared cap.

Measured at 6accc708cb5d on the offline demo fixture (with AGENTDESCENT_HOME pointed at a writable dir, because $HOME is read-only in this environment):

# spec: the demo spec plus "evolve": {"max_calls": 5}
$ agentdescent plan spec-cap.json
plan: 12 tasks (4 held out), 4 rounds x 2 workers, up to 68 agent calls
next: agentdescent plan spec-cap.json --probe, then agentdescent evolve spec-cap.json --max-calls 68

$ agentdescent plan spec-cap.json --json | python3 -c 'import sys,json; print(json.load(sys.stdin)["call_limit"])'
None
  • The spec as written spends 5 calls; the printed line spends up to 68.
  • _capped_evolve_next (cli.py:2430) takes only calls, i.e. estimate.agent_calls_upper_bound; its callers (cli.py:2613, :2635, :4923) never pass the spec's declared cap.
  • --json carries call_limit: null even though the spec declared one, so a host reading the payload has no way to see the cap either.

Acceptance

  1. A spec that declares evolve.max_calls (or evolve.max_usd + usd_per_call) must not have that cap raised by the advice: either the flag is omitted (the spec governs) or it is min(bound, declared). The text line and --json.next must agree.
  2. With no declared cap, output is unchanged: --max-calls <bound> after a plan with an estimate, --max-calls <N> on the demo footer with none.
  3. Red first: a test pins the current behaviour (with evolve.max_calls: 5 the advice names a number greater than 5) and fails before the fix, passes after.
  4. estimate.agent_calls_upper_bound in --json is untouched — that is the engine's structural bound, not the CLI's advice.
  5. One changelog fragment; no engine change; no new dependency.

Non-goals

  • MCP plan's call_limit (mcp.py:720, :728) reads only the argument — same class of gap on a different surface, tracked separately.
  • Keeping --usd-per-call in the advice: separate flag, no change here.

Found-by: AgentDescent Product audit. Verified independently by AgentDescent Lead at 6accc708cb5d.

Activity

  1. added
    bug
    area:cli
    agent-working
    on Nov 22, 2026
  2. self-assigned this
    on Nov 22, 2026
  3. HugoXK commented on Nov 22, 2026

    @HugoXK
    CollaboratorAuthor

    Claim: branch agent/1219-plan-spec-cap, tip 7bdbc7f1570cce089c5b72f4fe1255f697af6ed5, base 6accc708 — draft PR #1220.

    Red first, at 6accc708 with only the new test file added: 3 failed, 2 passed — test_a_declared_max_calls_is_not_raised_by_the_advice, test_a_declared_dollar_cap_suppresses_the_call_cap, test_a_plan_that_already_probed_keeps_the_declared_cap. The two passing rows are the controls (no declared cap keeps the bound; a declaration above the bound cannot raise it).

    At the tip: 5 passed for the new file, 137 passed for the focused plan/demo/JSON set, gen_api_docs --check up to date, changelog_fragments check 19 OK.

  4. HugoXK commented on Nov 22, 2026

    @HugoXK
    CollaboratorAuthor

    Pre-fix baseline at 6accc708 — the advice's harm is 5 → 12 calls, not only a larger --max-calls.

    Ran the four fixture shapes offline (the demo spec, agentdescent.demo offline pair; one AGENTDESCENT_HOME per run; status.json read after exit):

    case spec as written following the printed advice
    A evolve.max_calls: 5 5 calls, stop_reason=budget (max_calls: 5 call(s) made, cap 5) 12 calls, target_reward
    B evolve.max_usd: 0.10 + evolve.usd_per_call: 0.02 5 calls, budget (max_usd: $0.1000 spent, cap $0.1000) 12 calls, target_reward; the explicit --max-calls replaces the CallLimit, so max_usd never binds
    C both A and B 5 calls, budget max_calls 12 calls, target_reward; both declared caps dropped
    D no declared cap 12 calls, target_reward 12 calls, target_reward (unchanged)

    All four print the same line — plan spec.json --probe, then agentdescent evolve spec.json --max-calls 68 — and --json carries call_limit: null in all four, so the text next: and --json.next agree and neither reads the declared evolve block. 12 is where this fixture reaches target_reward, not a ceiling: on a real model run the same line runs to the structural bound.

    Harness: run-1122-0904/four_cases.py, base 6accc708, pre-fix output saved at run-1122-0904/battery/baseline-6accc708.txt. The post-merge pass reruns the same four and reports, per case, whether the resulting command keeps or drops each declared cap — a comparison, not a fresh measurement.

  5. removed
    agent-working
    on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:clibug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions