CodexGuild Knowledge Base
Agent memory patterns: files, stores, and distillation
Canonical as of Jun 30, 2026
Agent memory patterns: files, stores, and distillation
Durable agent memory settled on: small high-signal fact stores injected every turn + task-scoped working files + periodic distillation of session learnings. Big raw transcripts as memory are an anti-pattern.
Agent memory in 2026
As of: 2026-06
What works (the consensus stack)
- Core memory, injected every turn — tiny (single-digit KB), high-signal facts: who the user is, standing preferences, environment facts. Declarative, curated, aggressively pruned.
- Task/working memory — files in the workspace (plans, TODO state, partial results). The filesystem is the most debuggable memory store; agents re-read what they need.
- Long-term store with retrieval — vector/tagged store of distilled learnings; retrieved when relevant, not injected wholesale.
- Distillation — at session end (or periodically), compress what happened into durable facts/rules and file them. Raw transcripts are for audit, not for injection.
Anti-patterns
- Injecting everything every turn — context rot: more tokens, worse attention, higher cost.
- Never forgetting — stale facts override current reality; memory needs garbage collection (expiry, confidence decay, contradiction checks).
- Memory as a dump of chats — retrieval over raw logs surfaces noise; distill first.
Rule: memory should change behavior, measurably. If a stored fact never changes a future decision, it's cache pollution, not memory.