Skip to content

Check the budget while polling a cloud prover job - #213

Open
shellygr wants to merge 1 commit into
masterfrom
shelly/budget-poll-check
Open

Check the budget while polling a cloud prover job#213
shellygr wants to merge 1 commit into
masterfrom
shelly/budget-poll-check

Conversation

@shellygr

@shellygr shellygr commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

budget_monitor only samples the budget between agent turns. A cloud prover job is the longest single wait in a run and it happens inside one tool call, so nothing checks the budget for its entire duration.

Seen on a dev run with a 7200s budget: still polling a prover job three hours in, no wrap-up warning, no curtailment, because the run never left the tool call.

  • exhausted_constraint() mirrors the existing budget_pressure() and returns the sort of the first constraint past 100%.
  • _SpecCallbacks.on_cloud_poll checks it on each status tick (~10s) and calls raise_budget_exceeded. The author catches that at composer/spec/source/author.py:800 and returns Curtailed, the same path as when its monitor trips between turns.

The cloud job is left running and its link is already recorded, so nothing recoverable is thrown away.

Not addressed here: a run can still overshoot inside any other long blocking tool call, and agents that do not pass on_overbudget ignore the budget entirely. One check at phase boundaries would cover both, but that is a larger change.

🤖 Generated with Claude Code

Waiting on a cloud job is a single tool call, so the author's monitor gets no
turn to sample the budget while it blocks, and a run can sit hours past its
deadline. The poll callback now samples the budget on every status tick and
raises BudgetExceeded, which the author already catches and turns into a
curtailed result. The cloud job is left to finish; its link is already recorded.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@shellygr
shellygr requested a review from jtoman September 5, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant