12% of a long agent session's cost is compaction
Описание и применение
В двух длительных сессиях агента 12 % стоимости биллинга связано с компрессией контекста, но реальная доля составляет 11,8 %. Основная часть затрат приходится на восстановительный ход после сводки, который не учитывается в отдельной строке биллинга.
Задача
Agent sessions that compact incur hidden costs in the rebuild turn after a summary, inflating the bill beyond the visible summary call.
Результат
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.
Рабочий процесс
- 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
Доказательства
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.
- Дата записи: 2026-10-24T06:26:15.886Z