cd /news/ai-agents/compaction-turns-rewrote-my-agent-s-… · home › topics › ai-agents › article
[ARTICLE · art-182402] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

Compaction turns rewrote my agent's plan mid-flight — learning which facts survive summarization

A developer whose long-running agent session hit the context ceiling around turn 40 found that runtime compaction preserved decisions but dropped their rationale, causing the agent to undo a planned migration on turn 41. The engineer now writes decision rationales into the repo as ADR files referenced by path, phrases constraints as the first line of system blocks, and stamps retrieval order so it can be re-verified against a source rather than trusted in-context.

recommendation

Write load-bearing decision rationales into the repo as ADR files referenced by path, and put constraints as the first line of each system block so compaction cannot erase them.

more in playbook: Designing agent systems
by read1 min views2 publishedDec 5, 2026

A long-running agent session of mine hit the context ceiling around turn 40. The runtime compacted: it summarized the middle of the conversation into a paragraph and kept the ends. The user-facing summary looked fine. Then on turn 41 the agent undid a migration it had planned on turn 35, because the plan's rationale had lived entirely inside the compacted span.

The summary kept the what ("we decided to migrate the auth store") and dropped the why ("the new file format breaks round-trips on Windows paths"). It also dropped a constraint I'd stated in plain prose rather than as code. Three compaction lessons I now take seriously:

Anything load-bearing must be re-stated or materialized. If a decision rationale only exists in conversation text, assume the next compaction kills it. I started writing decisions into the repo as ADR files and referencing them by path, so compaction can't erase the reasoning, only the pointer.

Constraints beat facts. Summarizers preserve conclusions and drop qualifications. I now phrase constraints as the first line of every system block: "never X" before "we are doing Y". It survives better.

Compaction is a lossy transform, not a truncate. The hardest bug was ordering: after compaction, retrieved chunks from a memory search showed up ordered by similarity, but the summary had re-articulated them in a different order, contradicting the retrieved original. I now stamp retrieval order and re-verify it against a source rather than trusting the in-context version.

The agent that ships reliably is the one that treats its own memory as adversarial. Plan for the paragraph that remains, not for the conversation you actually had.

── more in #ai-agents 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/compaction-turns-rew…] indexed:0 read:1min 2026-12-05 · —