Repository navigation
fix(cli): name the spec's own call cap in plan's next line - #1220
Merged
Merged
Conversation
`runstore.py` states the rule: an explicit run option wins over a spec knob. `plan`'s `next:` printed `--max-calls` at the structural bound regardless, so a spec declaring `evolve.max_calls: 5` was advised to run with 11 -- following the advice raised the user's own cap. Red at 6accc70 with only this file added: 3 failed, 2 passed. The two that pass are the controls: no declared cap keeps the bound, and a declaration larger than the bound cannot raise it. Fails again if the advice stops agreeing with `--json.next`.
`_declared_cap(spec)` reads `evolve.max_calls` (or the `max_usd` + `usd_per_call` pair) and `_capped_evolve_next` now takes it: the advice is `min(bound, declared)`, or carries no `--max-calls` for a dollar cap it cannot express in calls. The three call sites (`_cmd_plan`, its already-probed branch, and `algorithms run`) pass it, so `next:` and `--json.next` stay one string. The demo footer keeps its `--max-calls <N>` placeholder: its own spec declares no cap. `estimate.agent_calls_upper_bound`, the engine, and MCP `plan`'s `call_limit` are untouched (#1219 scope).
A spec that declares `evolve.max_calls` and `max_usd` + `usd_per_call` was advised `--max-calls min(bound, declared)`; an explicit flag builds its own `CallLimit` and replaces the spec's, so following the advice dropped the declared dollar cap. Assert the both-declared spec prints no `--max-calls` on either surface.
`_declared_cap` returned the `max_calls` branch first, so a spec that declared both caps was advised `--max-calls min(bound, n)`. An explicit flag builds its own `CallLimit` and `overrides["call_limit"]` replaces the spec's (`runstore.py`), so the advice dropped the declared dollar cap. Check `max_usd` + `usd_per_call` first and recommend no flag: the spec governs. Fragment and docstring follow.
Collaborator
Author
|
State change: draft -> ready for review. Reason: the gate set for tip
No tip move with this flip. Merge side unchanged: draft -> ready is the only field changed. |
HugoXK
marked this pull request as ready for review
November 23, 2026 00:42
Collaborator
|
Review (Birfy) Tip SHA: 8954a0b
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1219
What changed
plan'snext:line and--json.nextadvisedevolve <spec> --max-calls Nat the structural bound even when the spec declared its own cap, and an
explicit flag wins over a spec knob (
runstore.py: "an explicit run option isthe sharper instruction"). Following the advice raised the user's cap.
Before (demo-shaped 8-task fixture +
"evolve": {"max_calls": 5}, bound 11):After:
_declared_cap(spec)readsevolve.max_calls, or themax_usd+usd_per_callpair;_capped_evolve_nexttakes it and printsmin(bound, declared), or no--max-callsat all for a dollar cap thecommand line cannot express in calls.
--max-callsbuilds itsown
CallLimitandoverrides["call_limit"]replaces the spec's(
runstore.py:1017-1021), so for a spec declaring both caps the advice addsno flag and the declared dollar cap still governs. Before that ordering fix
(tip
7bdbc7f1), the both-declared fixture printed--max-calls 5; now itsnext:readsagentdescent plan spec.json --probe, then agentdescent evolve spec.json, in text and in--json.next._cmd_plancli.py:2613and itsalready-probed branch
:2635,algorithms run:4923), so the text lineand
--json.nextare one string by construction.--max-calls <N>: the specdemowrites declaresno cap.
Out of scope and untouched:
estimate.agent_calls_upper_boundin--json(the engine's structural bound), MCP
plan'scall_limit(mcp.py:720/728),the engine, and
--usd-per-callin the advice.Verification at the tip
Tip SHA:
8954a0b043ee24355eb91159d06cf97fe9dee64cRan:
6accc708, only that file added →4 failed, 2 passed(thethree original rows plus the both-caps row; measured with the final six-row file)
7bdbc7f1, before the ordering fix →1 failed, 5 passedpytest -q -o addopts='' tests/test_plan_next_respects_spec_cap.pyat the tip →6 passed138 passedpython -m tools.gen_api_docs --check→docs/api.md is up to datepython -m tools.changelog_fragments check→19 changelog fragment(s) OKNot run:
pytest -q— the CI matrix is the line for this CLI-text changemkdocs build --strict— nodocs/page ormkdocs.ymlchangeDraft on purpose: the review lane is full; the Lead flips it ready when a slot frees.