Agent memory bloat happens when the system writes too much and retrieves too broadly. The result is noisy recall and higher prompt cost. Fix it by tightening the write path, deduping repeated facts, storing source-linked summaries, limiting retrieval payloads, and measuring cost per query.
Last updated: June 20, 2026.
What causes memory bloat?
Memory bloat usually starts with a generous write policy. The agent stores raw turns, temporary tool output, duplicate decisions, and unsupported guesses. Retrieval then returns a large context pack, and the model pays to read material that should never have been durable memory.
OpenAI’s conversation state guide frames state as application-managed. That means the application must decide what to keep. If it keeps everything, the agent inherits the cost.
How does bloat affect quality and cost?
Bloat affects both:
| Bloat symptom | Quality effect | Cost effect |
|---|---|---|
| Duplicate memories | Agent sees repeated facts | More tokens per answer |
| Stale memories | Old facts compete with current facts | More debugging and retries |
| Raw transcripts | Important decisions buried in chatter | Large context packs |
| Missing lifecycle | Deleted/superseded facts still retrieve | Wasted retrieval and prompt spend |
| Broad scope | Irrelevant tenant or project facts appear | Larger candidate sets |
The memory cost calculator helps compare context-stuffing cost with memory retrieval credits. Use it after you know how much context your system sends.
How should you inspect bloat?
Measure:
- Memory writes per session.
- Duplicate facts by source and text similarity.
- Retrieval candidates per query.
- Final prompt tokens from memory.
- Number of sources without citations.
- Number of memories with no retrieval in the last review period.
- Old facts without supersession state.
The MCP architecture docs explain server tools and resources. Your memory server should expose enough operational data to inspect these counts.
How do you reduce bloat?
Use a stricter write gate:
- Reject transient tool output.
- Require source or user confirmation for durable facts.
- Merge duplicates.
- Mark old facts superseded.
- Summarize long sources while keeping citation spans.
- Limit retrieval by tenant, library, type, and lifecycle.
- Review memories that never retrieve.
Do not solve bloat only by deleting old memories. Some old memories are valuable history. The right fix is lifecycle and retrieval discipline.
What should you store instead?
Store durable source-linked facts:
- Decisions.
- Stable project rules.
- User preferences.
- Current source summaries.
- Corrections.
- Supersession relationships.
- Delete tombstones.
Keep working context, scratch notes, and local command noise out of long-term memory.
What is a practical cleanup cadence?
Review memory on a schedule tied to usage, not only calendar time. For a busy coding agent, inspect the most retrieved memories weekly and the never-retrieved memories monthly. For a low-volume assistant, review after major source imports or product policy changes.
The review should answer three questions: which memories are valuable, which are stale, and which are duplicates. Valuable memories stay. Stale memories get superseded or deleted. Duplicate memories get merged behind one source-backed current fact.
How do you keep cleanup safe?
Avoid blind pruning by age. An old architectural decision may still be the highest-value memory in the library. A recent transcript snippet may be worthless after the task ends.
Use lifecycle states instead:
| State | Retrieval behavior |
|---|---|
| Current | Eligible for normal answers |
| Historical | Inspectable, but not preferred |
| Superseded | Shown only when history matters |
| Deleted | Excluded from active retrieval |
Those states let cleanup reduce prompt cost without destroying useful history. They also make retrieval behavior predictable when an agent asks why an older fact changed.
Track cleanup decisions as memories too when they affect future retrieval. “Archived duplicate onboarding snippets on June 20, 2026” is a useful audit note, not prompt context.
What should you read next?
Read Memory needs a write path, What agent memory costs, and Context Rot. Use the failure-mode catalog when bloat appears with stale or contradictory answers.