Check the budget while polling a cloud prover job - #213
Open
shellygr wants to merge 1 commit into
Open
Conversation
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>
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.
budget_monitoronly 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 existingbudget_pressure()and returns the sort of the first constraint past 100%._SpecCallbacks.on_cloud_pollchecks it on each status tick (~10s) and callsraise_budget_exceeded. The author catches that atcomposer/spec/source/author.py:800and returnsCurtailed, 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_overbudgetignore the budget entirely. One check at phase boundaries would cover both, but that is a larger change.🤖 Generated with Claude Code