Skip to content

fix(budget): count context compaction in the task spend - #1170

Draft
sosidudku1 wants to merge 2 commits into
mainfrom
fix/ato-1322-compaction-spend
Draft

sosidudku1 wants to merge 2 commits into
mainfrom
fix/ato-1322-compaction-spend

Conversation

@sosidudku1

@sosidudku1 sosidudku1 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • New unit test for recordCompactionSpend in src/agent/turn/turn-spend.test.ts. The wiring (runner → onSpend → turn spend) has no test of its own yet.
  • Not run yet: lint, tsc and vitest go in one combined pass on the second Mac.

Merge notes

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.

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

No deployments
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