Agent’s own prior output is the #1 uncached cost driver at 35.2% — need conversation history compaction
Problem
In long-running Antigravity sessions, the agent’s own prior output (PLANNER_RESPONSE messages) re-enters the context as uncached input on every subsequent turn. This creates an asymmetry: the agent’s response is cheap when produced (1.6% of total cost as output tokens), but that same text becomes the single most expensive input category as it accumulates across turns.
Measured Impact
Data from a production 2,422-step conversation (52313444, 8-day build session, 5,163 transcript lines):
Cost structure:
| Category | Token Volume | Cost Contribution |
|---|---|---|
| Uncached input | 44,181,168 | 60.6% |
| Cached input (×0.1) | 275,951,379 → 27.6M effective | 37.8% |
| Output | 1,161,459 | 1.6% |
Uncached input decomposition (top 5 of 18 message types):
| Message Type | Count | New Tokens | % of Uncached | Avg Tokens |
|---|---|---|---|---|
| PLANNER_RESPONSE | 2,456 | 1,157,507 | 35.2% | 471 |
| VIEW_FILE | 576 | 1,071,523 | 32.6% | 1,860 |
| CODE_ACTION | 434 | 210,062 | 6.4% | 484 |
| RUN_COMMAND | 745 | 196,953 | 6.0% | 264 |
| CHECKPOINT | 62 | 184,613 | 5.6% | 2,978 |
PLANNER_RESPONSE is 35.2% of uncached input — the #1 contributor, ahead of VIEW_FILE (32.6%) and every tool result combined.
The Asymmetry
The same text has radically different costs depending on when it appears:
- When produced (output): 1.6% of total cost — negligible
- When re-read (uncached input on subsequent turns): 35.2% of uncached = 21.3% of total cost
Every PLANNER_RESPONSE at 471 average tokens costs very little to generate, but that 471 tokens comes back as uncached input on every future turn in the conversation. A 200-turn conversation accumulates ~94K tokens of PLANNER_RESPONSE history, all re-processed as uncached input.
Why This Matters: Correction Cycles
Measured across 181 real conversations (94 correction cycles):
| Metric | Value |
|---|---|
| Average turns per correction cycle | 107.5 |
| Correction cycles via stage transition | 12 (avg 343.7 turns) |
| Correction cycles intra-stage | 82 (avg 72.9 turns) |
A single correction cycle averaging 107 turns accumulates approximately 50K tokens of PLANNER_RESPONSE that re-enter as uncached input on every subsequent turn. The agent’s own prior output during correction is the primary driver of escalating per-turn cost in long sessions.
Current Behavior
All prior PLANNER_RESPONSE messages remain in the conversation context at full fidelity. Prompt caching helps when the prefix is stable, but any context change (new message, tool result) can invalidate the cache, forcing the full history to be re-processed as uncached input.
In the measured session: 207 cache misses out of 2,422 steps (8.5%), each re-processing ~131K tokens of accumulated history at full cost.