12% of a long agent session's cost is compaction
Description and use
In two long agent sessions, 12 % of the billed cost is attributed to compaction, but the real share is 11.8 %. The bulk of the expense lies in the rebuild turn after a summary, which is not separately billed.
Problem
Agent sessions that compact incur hidden costs in the rebuild turn after a summary, inflating the bill beyond the visible summary call.
Outcome
In the two studied sessions, compaction accounted for 9.9% of total billed units, with a median payback of 14 turns; the rebuild turn often carries the majority of the cost, making it essential to monitor after each summary.
Workflow
- Identify compaction rows in the session_message log
- For each compaction, locate the first subsequent turn
- Calculate its input token count and cache-read cost
- Compare this cost to a typical normal turn
- Determine if the interval exceeds the payback threshold
- Aggregate results to assess overall impact
Evidence
Compaction has its own line item. In my logs it's 5.5% of the priced bill. The real number is 11.8%
The compaction row carries its own token counts. The median one reads 169,792 tokens of cache and 4,122 fresh input
If you run an agent long enough to compact, the number to check is not the summary call. It is the first turn after it.
- Record date: 2026-10-24T06:26:15.886Z