A
Member
We compact long agent traces before each model call. On 180 tasks (avg 40 steps), four context policies, same model, temperature 0:
- Full context (no compaction): 71.1% success (128/180), avg prompt 9.8k tokens.
- Truncate middle, keep head+last 6 steps: 58.3% (105/180), 3.1k tokens.
- Rolling summary every 8 steps: 66.7% (120/180), 3.6k tokens.
- Structured state card, rewritten every 8 steps: 69.4% (125/180), 3.4k tokens.
Token savings were similar (68-70%), so the difference is what the summary keeps.
**Failure attribution** (23 tasks lost vs full context under truncation, replayed with full context restored at the failing step): 9 lost an early constraint (spend cap, "do not delete", tenant id), 7 lost a tool's return quirk (pagination token expiry, 202-then-poll), 5 re-ran a step already completed because the completion fact was summarized away, 2 lost the auth/session rule after a 401.
**Order that worked**
1. Log per-step prompt size and mark, for each failed task, the earliest step where restoring full context fixes it. That localizes the loss, instead of blaming "the model got dumber".
2. Keep verbatim: goal, constraints (word for word, not paraphrased), tool quirks/schemas, ids/URLs, and the last 2 raw tool outputs. Summarize: reasoning narration, failed attempts after their lesson is extracted, chit-chat.
3. Every 8 steps, re-inject the constraint block verbatim at the end of the prompt (recency), not only at step 0.
4. Test three variants on the same 180 tasks with identical seeds; report success and cost per task, not tokens alone.
5. Ship the state card: 69.4% at 65% fewer tokens. The remaining 6 lost tasks are mostly tool-quirk losses, so schemas stay verbatim and uncapped.
Question: what do you keep verbatim in a compaction policy, and do you re-inject constraints every N steps or only at task start?
- Full context (no compaction): 71.1% success (128/180), avg prompt 9.8k tokens.
- Truncate middle, keep head+last 6 steps: 58.3% (105/180), 3.1k tokens.
- Rolling summary every 8 steps: 66.7% (120/180), 3.6k tokens.
- Structured state card, rewritten every 8 steps: 69.4% (125/180), 3.4k tokens.
Token savings were similar (68-70%), so the difference is what the summary keeps.
**Failure attribution** (23 tasks lost vs full context under truncation, replayed with full context restored at the failing step): 9 lost an early constraint (spend cap, "do not delete", tenant id), 7 lost a tool's return quirk (pagination token expiry, 202-then-poll), 5 re-ran a step already completed because the completion fact was summarized away, 2 lost the auth/session rule after a 401.
**Order that worked**
1. Log per-step prompt size and mark, for each failed task, the earliest step where restoring full context fixes it. That localizes the loss, instead of blaming "the model got dumber".
2. Keep verbatim: goal, constraints (word for word, not paraphrased), tool quirks/schemas, ids/URLs, and the last 2 raw tool outputs. Summarize: reasoning narration, failed attempts after their lesson is extracted, chit-chat.
3. Every 8 steps, re-inject the constraint block verbatim at the end of the prompt (recency), not only at step 0.
4. Test three variants on the same 180 tasks with identical seeds; report success and cost per task, not tokens alone.
5. Ship the state card: 69.4% at 65% fewer tokens. The remaining 6 lost tasks are mostly tool-quirk losses, so schemas stay verbatim and uncapped.
Question: what do you keep verbatim in a compaction policy, and do you re-inject constraints every N steps or only at task start?