Engram Blog · Published July 29, 2026

Stop Paying for Context You Aren't Using: /clear Freely, Retrieve with MCP Memory

A long Claude Code session re-reads 100k+ stale tokens on every turn. Retrieving the same context from Engram costs about 2,000 — we measured it. Here's the math and the save → /clear → recall workflow.

If you use Claude Code seriously, you know the moment. The session has been running for hours, the context meter is creeping toward the ceiling, and the agent is starting to feel a little foggy. You hover over /clear and hesitate — because clearing means losing everything the session learned: the bug you traced, the decisions you made, the dead ends you already ruled out.

So you don't clear. You keep going, dragging a hundred thousand tokens of history into every single turn, paying for it over and over, until the harness force-compacts your session into a summary you didn't write and didn't get to review.

There's a better trade available, and the arithmetic is lopsided enough that it's worth seeing in actual numbers: carrying context costs six figures of tokens per turn; retrieving it when you need it costs about two thousand. This post walks through the real measurements, then the workflow.

Every turn re-reads everything

The part that's easy to forget: a language model has no working memory between turns. Every time you send a message, the entireconversation — system prompt, tool definitions, every file the agent read, every command output, every one of your messages — is fed back through the model as input tokens. A 150,000-token session doesn't cost 150,000 tokens once. It costs 150,000 tokens per turn, every turn, forever, until you clear or compact.

Prompt caching softens this — cached input is roughly a tenth the price of fresh input — but the cache has a short shelf life (about five minutes on Anthropic's API). Step away to review a PR, answer a Slack message, or get coffee, and the next turn re-reads your whole context at full price. Long agentic sessions are full of exactly those pauses.

And price is only half the problem. Models demonstrably reason worse over very long contexts: instructions from hours ago compete with the current task, stale file reads contradict the current state of the repo, and attention gets spread across everything you've ever said instead of the thing you're saying now. A five-hour session isn't just expensive — it's a worse collaborator than a fresh one.

What carrying context actually costs

Take a realistic afternoon: a session that's been alive for a few hours and is sitting at ~120,000 tokens of context, and you exchange 40 more turns with it.

  • Input volume: 40 turns × ~120,000 tokens ≈ 4.8 million input tokensprocessed — for context that's mostly about work you already finished.
  • With a warm cache(Sonnet-class pricing, ~$0.30 per million cached-read tokens) that's still about $1.44 of pure re-reading.
  • Every cache miss — every pause longer than five minutes — bills one full-price pass: ~$0.36 per resumed turn at $3 per million. A day with a dozen interruptions quietly adds dollars, and on subscription plans the same volume burns down your usage limits instead.
  • Then compaction hits anyway.Near the context ceiling, the harness summarizes your session to make room. The summary is lossy, you don't choose what survives, and the details that get dropped are — by Murphy's law — the ones you needed at 6 PM.

What retrieving context actually costs

We measured Engram's overhead directly, since we ship the server and can count the bytes. Two numbers matter.

1. The fixed cost: tool definitions.Connecting Engram over MCP puts its tool schemas (search, append, create, status, and friends) into your agent's context once per session. Serialized, that's roughly 1,000–1,500 tokens — about one percent of the context you were carrying around.

2. The per-recall cost: one search. We ran a real production query — five results, each with a full verbatim excerpt plus a one-line summary for triage — and the complete tool response came back at just under 8,000 characters, which is almost exactly 2,000 tokens. A tighter search with two or three results lands closer to 1,000. The query itself is a rounding error.

Saving costs even less. Appending a session summary — what you decided, what you shipped, what's still open — is a few hundred tokens of writing, done once, at the end.

The math, side by side

Per turn, for context about past work:

Carrying itRetrieving it
Tokens per turn~120,000, every turn, needed or not~2,000, only on turns that actually recall
Fixed overhead~1,500 tokens of tool schemas, once per session
Survives /clear, reboots, new machinesNoYes
FidelityDegrades, then force-compacted into a lossy summaryVerbatim — the exact words, months later

On the turns where you need history, retrieval is roughly 98% cheaperthan carrying a 120k context. On the turns where you don't need history — most of them — it's free, because you simply don't search. That asymmetry is the entire argument: carrying makes every turn pay for the past; retrieval makes only the turns that use the past pay for it, and only ~2,000 tokens at that.

The workflow: save, clear, recall

With Engram connected to Claude Code over MCP, the loop is three moves.

1. Save before you clear

At any natural boundary — a PR merged, a bug closed — say:

> save this session to engram: what we shipped, the decisions
  we made and why, and what's still open

The agent writes a conversation to Engram with the full detail — not a compaction-style summary, but the actual content you asked it to preserve, in its own words, stored verbatim.

2. Clear without flinching

> /clear

Context drops back to the baseline. The fog lifts. Your next turn is sharp, cheap, and fully cached.

3. Recall only when you need it

> search engram for what we decided about the auth
  middleware refactor

One search, ~2,000 tokens, and the agent has the exact decision — including the reasoning — pulled from a session that might have been yesterday or last quarter. It works across machines and across tools: recall in Cursor what you decided in Claude Code.

Make it automatic with CLAUDE.md

The workflow gets better when you stop doing it by hand. Add a few lines to your project's CLAUDE.md and the agent handles both ends itself:

## Memory (Engram)

- On session start: search Engram for context relevant to the
  task before diving in.
- When significant work concludes (feature shipped, bug fixed,
  decision made): store it in Engram with the reasoning.
- Prefer /clear at task boundaries over long sessions. Context
  you might need later belongs in Engram, not in the window.

We run this pattern on Engram's own repos. Sessions start lean, end with a save, and the project's institutional memory lives in a place where /clearcan't touch it.

When NOT to clear

Honesty section: /clearis not always the right move. Mid-investigation — while the agent is holding a dozen open threads about a bug it hasn't cracked — the live context is the working state, and no summary fully substitutes for it. The rule of thumb we use:

  • Clear at boundaries, not in the middle of a thought: after a merge, after a decision, after a write-up.
  • Save first when the session produced anything you'd mind losing— and say what to save, so the record reflects your judgment instead of an auto-compactor's.
  • If the context meter is near the ceiling, the decision has already been made for you — the only question is whether the summary that survives is one you wrote to Engram or one the harness wrote for itself.

The context window is a scratchpad, not a filing cabinet. Use it like one: work hot, save what mattered, wipe it clean, and pull things back only when they earn their two thousand tokens.

Give your agent a memory that survives /clear

Free tier, no credit card. Connect Claude Code or Cursor with a copy-paste MCP config and start saving sessions in two minutes.