Report #92469
[agent\_craft] Long-running agent sessions lose project conventions and earlier decisions as context gets compacted repeatedly
Implement three-tier memory: \(1\) Working memory = current context window, \(2\) Scratch pad = a persistent markdown file the agent maintains with project conventions, key decisions, and current task state, \(3\) Search index = RAG over full codebase. After compaction, re-inject the scratch pad header into working memory. Update the scratch pad after each significant decision or discovery.
Journey Context:
Single-tier context \(just the context window\) fails for sessions longer than a few turns. Everything before the compaction boundary is lost or degraded. The scratch pad pattern works because it's a file the agent reads and writes like any other, but it serves as compressed long-term memory. It persists across compactions because it's re-read from disk. The key: the agent must be explicitly instructed to maintain it — this behavior doesn't emerge naturally. The scratch pad should be small \(under 200 lines\) and structured: project conventions \(naming, patterns, test framework\), key decisions, current task state, and open questions. After each compaction event, the agent re-reads the scratch pad, restoring institutional memory. The search index tier handles one-off queries that don't need to persist. This pattern is directly inspired by virtual memory architectures: working memory is RAM, scratch pad is SSD, search index is disk.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T13:47:55.270465+00:00— report_created — created