Files
open-code-review/skills
Micah Goulart 8d57bc9e83 fix(agent): enforce --max-tokens-budget inside a running group (#1248)
* fix(agent): enforce --max-tokens-budget inside a running group

The budget was only checked when the next group was dispatched, so a review with fewer groups than --concurrency could never hit it. Check it before every LLM round, give the over-budget group one final round to submit findings, and report it as failed(budget).

* fix(agent): record the budget when the round gate skips a round

The round gate in executeGroupSubtask breaks out of the round loop when the
aggregate budget is already spent, but it was the only budget stop that did
not set budgetExceeded. A group whose round finished normally — task_done,
findings submitted — and only then tripped the gate left the run reporting
the budget as intact, because no other gate ever looked again. It now records
the stop the same way the in-conversation check does, with a warning naming
the skipped round, the group, and the usage against the cap.

The grace round stays on StopTokenBudget, in answer to the review on this PR.
It is one bounded call whose whole job is to let the model submit findings it
already has; skipping it spends the tokens the run has already paid for and
throws the findings away. What was missing was not the skip but the record,
plus docs that say the cap is checked before every round rather than only at
dispatch — the cli-reference and CI input tables in all five locales now say
so.

Test covers the gate specifically: a group whose round 1 ends in task_done
already over budget must not start round 2, must not get a grace round (it has
nothing unreported), must stay classified completed, and must still report
BudgetExceeded.
2026-09-17 20:30:45 +08:00
..