Repository navigation
fix(budget): count context compaction in the task spend - #1170
Draft
sosidudku1 wants to merge 2 commits into
Draft
sosidudku1 wants to merge 2 commits into
sosidudku1 wants to merge 2 commits into
Conversation
A compaction's summary calls are side calls, not step completions, so recordStepSpend never priced them and a long overnight run that compacted could spend past its budget unnoticed. The runner now reports each attempt's summary cost through CompactionStepOptions.onSpend, and the loop adds it to the turn spend at all three compaction sites. ATO-1322
This branch has not been deployed
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.
What
A context compaction's summary calls are side calls, not step completions, so the task spend ceiling never counted them. A long overnight run that compacted could spend past its budget. The compaction runner now reports each attempt's summary cost (saved or failed) through a new
CompactionStepOptions.onSpend, and the loop adds it to the turn spend at all three compaction call sites (before a step, after a steer, and the overflow retry).Why
"Stop at the budget" should hold for every paid call the run makes. Linear: ATO-1322.
Background compaction between turns (
compaction:<id>usage) is not part of a task turn and stays outside the task budget.How it was verified
recordCompactionSpendinsrc/agent/turn/turn-spend.test.ts. The wiring (runner →onSpend→ turn spend) has no test of its own yet.Merge notes
src/agent/agent-loop.ts. KeeprequestStartedAt = Date.now()right beforeexecuteStep.Checked on the second Mac on 12.11.2026 in the combined run with the other open PRs: build, lint, test types, vitest, desktop unit tests, desktop smoke and live smoke all green.