feat: warn the agent at 80% of a run budget before hard stop - #4179
Open
salignatmoandal wants to merge 1 commit into
Open
feat: warn the agent at 80% of a run budget before hard stop#4179salignatmoandal wants to merge 1 commit into
salignatmoandal wants to merge 1 commit into
Conversation
Collaborator
|
👋 Some commits in this PR are not signed and verified by GitHub. Please sign your commits with a GPG or SSH key registered in your GitHub account, then force-push. Commits that are not verified: See GitHub's guide on signing commits for setup instructions. I've added |
Give the model one chance to cheapen or finish before the existing kill-switch fires, without changing the budget_exceeded contract.
salignatmoandal
force-pushed
the
feat/soft-budget-warn
branch
from
September 5, 2026 10:33
8858c9a to
27b5686
Compare
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.
Summary
The budget already existed. The agent never saw it until the run was killed.
max_cost/max_tokens/max_time, then keep going.budget_exceededJSON contract and kill-switch at 100% are unchanged.Why this is interesting
enforceBudgetwas a fuse, not a policy. The runtime already counted cost, tokens, and time (record/snapshot/ per-agent spend), but the model only learned the ceiling afteriterationStop. From the user's point of view that looks like a crash: Execution stopped after reaching budget.max_cost.That is the EcoAgent-Bench gap: completing under a budget is not the same as choosing economical actions. A kill-switch with no feedback trains the agent to spend until the wall.
This PR turns the counters into a signal inside the loop — a change in agency policy, not an extra log line.
What that buys docker-agent:
What it does not claim:
Behavior
At the existing turn-boundary check in
RunStream:budget_exceeded+ assistant stop message +iterationStop).[80%, 100%)and that tracker has not warned for that limit yet:Warningevent (TUI / JSON stream)GetMessagescallexceeded()).Warningremains).Test plan
go test ./pkg/runtime -count=1 -run 'TestBudget|TestNilBudget|TestEnforceBudget|TestRecordBudget'go test ./pkg/runtime -count=1 -run 'TestBudgetExceededEventJSONContract|TestEnforceBudgetWarnsOnceThenStillHardStops'task testtask lint