Technology and AI
How to Manage Multi-Turn Conversation Memory in an AI Agent Without Blowing Up Token Costs

Pratik Chothani
Software Development Engineer
July 26, 2026
·4 min read
·Updated July 26, 2026

Quick answer
The naive approach (resending the full conversation transcript on every turn) makes cost grow with the square of conversation length, because every past message gets re-billed every time. The fix is layered memory: keep only recent turns verbatim in context, summarize or compress older turns into compact facts, and retrieve specific past details on demand instead of carrying them at all times. Combined with prompt caching for the stable parts of context, this typically cuts token costs by 50-90% with little to no quality loss for most conversational agents.
Why memory costs grow faster than conversations do
Every LLM call re-processes the entire input context, including everything sent in previous turns. If a conversation has 20 turns and each turn's full history gets re-sent, turn 20 is paying for roughly 20x the tokens of turn 1. And the total cost across the conversation grows quadratically, not linearly. A support conversation that runs long, or an agent that loops through several tool calls per user message, hits this wall fast, which is why token cost (not model choice) is usually the first thing that breaks a chat-agent's unit economics at scale.
Layer 1: keep a short verbatim window
Most of what makes a conversation feel coherent is the last few turns, not the first one. Keeping a sliding window of the most recent messages verbatim (and nothing older) handles the majority of "wait, what did I just say" continuity without carrying the entire history forward indefinitely.
Layer 2: summarize what falls out of the window
Rather than dropping older turns entirely, compress them into a running summary: key facts established, decisions made, unresolved questions. This is where most of the savings come from. A 2,000-token exchange can often compress to a 100-token fact without losing anything the agent actually needs to reference later. Structuring this as tiered memory (raw recent turns, summarized episodes, and distilled long-term facts) scales better than one flat growing transcript.
Layer 3: retrieve, don't carry, long-term facts
User preferences, account details, or prior-session context don't need to live in every prompt. They can sit in a separate store (a database, a vector index) and get retrieved only when relevant to the current turn. This is the same underlying pattern as RAG: pull in what's needed for this specific turn instead of keeping everything present at all times "just in case."
Use prompt caching for the parts that don't change
The system prompt, tool definitions, and any static reference material are identical across every turn in a conversation and often across many conversations. Prompt caching lets the model provider skip re-processing that stable portion, which is frequently the single highest-leverage cost lever available. It requires no architecture change, just structuring the prompt so the stable parts come first and stay byte-identical across calls.
Watch for the quality tradeoff
Aggressive summarization can quietly drop a detail the agent needed three turns later. A number, a constraint the user mentioned once. The fix isn't to avoid compression, it's to evaluate it: run real conversation transcripts through the memory pipeline and check whether answers that depend on early-turn facts are still correct after compression, the same way you'd evaluate any other change to a production agent. Getting this wrong shows up as the agent confidently forgetting or hallucinating something the user already told it, which is a worse failure than a slightly higher token bill.
It compounds with everything else that drives agent cost
Memory management is one lever alongside model choice and tool-call efficiency. All of which show up in the same per-conversation cost math worth tracking once an agent is live, not just at build time.
FAQ
How much can memory optimization actually save on token costs? Teams that combine summarization, retrieval, and prompt caching commonly report 50-90% reductions in per-conversation token spend compared to a naive full-history approach, with little to no perceived quality loss for the end user.
Does summarizing conversation history hurt the user experience? Not if it's tuned correctly. Users rarely notice that turn 3's exact wording was compressed into a summary; they do notice if a fact from turn 3 disappears entirely, which is why evaluation against real conversations matters more than the compression method itself.
Should every agent use tiered memory, even simple ones? No: a short-lived, low-turn-count agent (a one-shot Q&A bot) doesn't need this complexity. Tiered memory earns its cost once conversations regularly run long or an agent loops through multiple tool calls per turn.
Is prompt caching enough on its own, without summarization? It helps significantly for the static portions of a prompt, but it doesn't solve the growing-transcript problem. The conversation history itself still needs a compression or retrieval strategy as it gets longer.
Accelate designs agent memory as a layered system from day one (recent context, summarized history, and retrieved facts) so token costs stay predictable as real conversations get longer than a demo ever does.
Related posts