Last verified

What is auto-compact in Claude Code?

Auto-compact.

Auto-compaction is Claude Code summarising older conversation history when a session approaches the model's maximum input size, to free space for the work still ahead. Anthropic lists it beside prompt caching as one of two automatic cost optimisations. The important part for anyone who's seen the warning: it signals a context boundary, not a usage or billing limit.

What triggers it
Context limit conversation nears max input
What it does
Summarises older history, keeps recent
Is it a usage cap?
No docs say so explicitly
Why it exists
Cost + fit tokens scale with context
Sibling feature
Prompt caching the other auto-optimisation
Side effect
Detail loss summaries aren't transcripts
§ 01 / SOURCE

Where this answer comes from.

Methodology →
PER VENDOR DOCS · AUG 01, 2026

The doc corrects the usual misreading directly.

Anthropic's cost guidance describes it plainly: Claude Code "automatically optimizes costs through prompt caching, which reduces costs for repeated content like system prompts, and auto-compaction, which summarizes conversation history when approaching context limits".

And in the troubleshooting list, the misconception is named outright: a context or auto-compact warning is "not a usage limit" — the conversation has simply grown close to the model's maximum input size, and Claude Code summarises older history to free space. Anyone arriving here after seeing that banner mid-task is usually worried about the wrong thing.

The reason both features exist is the same arithmetic: token cost scales with context size, so the more history the model carries, the more each turn costs. Compaction trades fidelity for room.

Trigger: near max input sizeAction: summarise older historyUsage limit?: noPaired with: prompt caching
!
Per vendor docs — we did not run this test. The answer above rests on the source below, read on . Where we run a capability ourselves, this section carries the terminal transcript instead.
Source Anthropic docs — Manage costs effectively, context and auto-compaction https://code.claude.com/docs/en/costs
§ 02 / WHY

What it means for your session.

2.1
Why long sessions start forgetting

A summary is lossy by definition. After compaction the model still knows the shape of what happened — decisions taken, files touched — but not every line of the transcript that led there. That's the practical cost, and it's why a very long session sometimes repeats a question you answered an hour ago.

The defence isn't fighting the feature; it's keeping durable facts somewhere durable. Project instructions in CLAUDE.md survive compaction because they're re-read, not remembered.

2.2
It saves money, and so does avoiding it

Compaction reduces the context being carried, which reduces per-turn cost. But arriving at compaction at all means you've been paying to carry a large context for a while. Starting a fresh session for a new task is cheaper than compacting an old one, and gives better answers.

If you want to see what your context is actually costing, the usage panel flags long context when it accounts for 10% or more of recent usage.

2.3
Compaction versus caching

They pull in different directions and it's worth not confusing them. Prompt caching makes repeated context cheaper to send — the content stays, the price drops. Compaction makes the context smaller — the price drops because the content goes.

Caching is free money; compaction is a trade. Both happen automatically, which is why sessions can get cheaper and vaguer at the same time.

Frequently asked.

Quick follow-ups people search after this question.

Q · 01 Does auto-compact mean I've hit a usage limit? +
No, and Anthropic's docs state that explicitly. It means the conversation has grown close to the model's maximum input size, so older history gets summarised to make room. Your plan limits are a separate thing entirely.
Q · 02 Does compaction lose information? +
Yes — a summary isn't a transcript. Recent turns survive intact; older detail is compressed. Anything that must persist belongs in CLAUDE.md or a file, where it's re-read rather than remembered.
Q · 03 Can I avoid it? +
Mostly by not needing it: start a new session per task rather than running one enormous conversation. That's also cheaper, since you stop paying to carry irrelevant history on every turn.
Q · 04 Is compaction the same as prompt caching? +
No. Caching makes repeated context cheaper to send while keeping it; compaction shrinks the context by summarising it. Caching is a straight saving, compaction is a trade of detail for room.