{"slug": "compaction-turns-rewrote-my-agent-s-plan-mid-flight-learning-which-facts-survive", "title": "Compaction turns rewrote my agent's plan mid-flight — learning which facts survive summarization", "summary": "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.", "body_md": "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.\n\nThe 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:\n\nAnything 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.\n\nConstraints 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.\n\nCompaction 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.\n\nThe 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.", "url": "https://wpnews.pro/news/compaction-turns-rewrote-my-agent-s-plan-mid-flight-learning-which-facts-survive", "canonical_source": "https://dev.to/imapphelp/compaction-turns-rewrote-my-agents-plan-mid-flight-learning-which-facts-survive-summarization-12m0", "published_at": "2026-12-05 12:01:26+00:00", "updated_at": "2026-12-05 12:13:28.289463+00:00", "lang": "en", "topics": ["ai-agents", "large-language-models", "ai-tools"], "entities": [], "also_reported_by": [], "takeaway": "Compaction is a lossy transform that keeps conclusions and drops qualifications, so materialize decision rationales as repo files referenced by path and lead every system block with constraints before facts.", "recommendation": {"advice": "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.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/compaction-turns-rewrote-my-agent-s-plan-mid-flight-learning-which-facts-survive", "markdown": "https://wpnews.pro/news/compaction-turns-rewrote-my-agent-s-plan-mid-flight-learning-which-facts-survive.md", "text": "https://wpnews.pro/news/compaction-turns-rewrote-my-agent-s-plan-mid-flight-learning-which-facts-survive.txt", "jsonld": "https://wpnews.pro/news/compaction-turns-rewrote-my-agent-s-plan-mid-flight-learning-which-facts-survive.jsonld"}}