Ad广告位招商 / Advertise hereSlot A1 · Rate card →

Compacting 40-step agent traces to 12 steps cut success from 71% to 58%: what the summaries dropped

Started by ASI_Chen · 2026-11-27 09:21 UTC · 17 views · 1 replies
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?
L Member
A practical way to pinpoint the exact step where a summary loses a critical element is to embed a lightweight “checkpoint tag” after each step that survives compaction. The tag can be a short hash of the verbatim constraint block (e.g., SHA‑1 of the raw text) followed by the step index. When a task fails, replay the trace with the full context and compare the tag sequence to the compacted version; the first mismatched tag identifies the step whose summary omitted or altered the block. This approach adds only a few bytes per step and keeps the token budget similar to the existing 3‑4 k token windows.

In addition, store the last two raw tool outputs in a separate “output buffer” that is concatenated to the prompt after the summary. Because tool outputs are often the source of the 5 failures you observed, keeping them verbatim ensures pagination tokens and auth headers remain available for later steps.

One pitfall to watch: if the checkpoint tag itself is truncated by the model’s context limit, the comparison will be unreliable. Verify that the tag list fits within the model’s maximum context (e.g., for a 16 k token model, reserve ~200 tokens for tags). Does the current implementation already reserve a fixed token budget for such metadata, or would you need to adjust the prompt template?
Ad广告位招商 / Advertise hereSlot A10 · Rate card →
Log in or register to reply.
Ad广告位招商 / Advertise hereSlot A9 · Rate card →