Axiom Lift

Claude Code · context

When compaction fails and the session dies: what to do next

Compaction errors, a context window you can't see filling, tool output cleared without notice. Why each happens in Claude Code, and the steps that get a session going again.

30 September 2026

A context meter filled to the limit, marked in red where the compaction failed

The issue, as reported

Compaction is the safety net: when the conversation fills the context window, the tool swaps the older part for a summary and carries on. Many developers report the moment it fails: the context is full, the compaction step errors out, and the session can neither continue nor shrink.

It is widely reported. Across the Claude Code, Codex and OpenCode issue trackers there are hundreds of reports of compaction failing, from well over three hundred developers since mid-2025, and they are still arriving. Nearly as many ask for something simpler: a way to see how full the context is before compaction arrives. A smaller group reports file reads and command output filling the window, then older tool results vanishing from what the agent sees.

What developers report

FailsThe first few compactions work, then every attempt errors, and the session can't go on
Stuck"Prompt is too long" or a timeout on every retry, often late in a long session at the worst moment
On diskThe full transcript is still on disk, with no obvious way back into it
BlindNo gauge of how full the context is, so compaction arrives mid-task without warning
ClearedOlder tool results drop out of what the agent sees, so it loses evidence it read earlier
RitualsExit and resume, compact again, switch model first, or keep auto-compact off and prune by hand

The fixes below are for Claude Code, whose error messages are documented in detail, with a note for Codex.

Why it happens

Each time you send a message, Claude Code sends the whole context again: the system prompt, your CLAUDE.md, every earlier message and every tool result (docs). That has a hard ceiling. By default, auto-compaction runs when the conversation reaches the model's context limit; on models with a native 1M window it runs at about 967K tokens (docs).

Compaction is itself a request to the model, so it can fail like any request. Claude Code's error reference separates three cases that look alike from the chair:

Three messages: Context limit reached (the window is full), automatic compaction failed (another error underneath), Autocompact is thrashing (one output refills the window)
The three messages look alike, but each has a different cause and a different first move.

A single-exchange conversation has nothing earlier to summarise, so it can't be compacted at all. And some fixes are recent: before v2.1.229 (August 2026) a failed compaction showed only "Prompt is too long", with no cause; before v2.1.269 (September 2026) a session that couldn't summarise a whole exchange hit the error again on every turn.

Tool output is the other half: every file read and command output stays in the conversation. Since v2.1.51, results over 50,000 characters are saved to disk with a preview in the conversation (changelog), and Claude Code also clears old tool results from context. The main place that is visible is a line in /usage, which counts it as an "expected rebuild (compaction or tool-result clearing)" (docs).

How to fix it today

These steps are for Claude Code and come from Anthropic's documentation.

  1. Update Claude Code

    Run claude --version, then claude update. Newer versions fix several of these failures and name the underlying error.

  2. Read the whole error line

    If it says automatic compaction failed: followed by a cause, fix that cause first (sign in again, or pick an available model with /model). Then run /compact.

  3. If it's thrashing, shrink the input

    Ask Claude to read the large file in parts (a line range or one function), run /compact with a focus that drops the big output, move large-file work to a subagent, or /clear if you no longer need the earlier conversation.

    /compact keep only the plan and the diff
  4. If the session won't move, restart and resume

    Exit, then run claude --resume in the same folder. The conversation is kept on disk, so restarting doesn't lose it. Then /compact, or /rewind, pick a message and choose Summarize up to here to compress everything before it and keep the recent part intact.

  5. See how full the context is

    Run /context for a breakdown of what is filling the window (system prompt, tools, memory files, messages) and which command frees space. For a gauge that is always on screen, add a status line to ~/.claude/settings.json:

    {
      "statusLine": {
        "type": "command",
        "command": "jq -r '\"[\\(.model.display_name)] \\(.context_window.used_percentage // 0)% context\"'"
      }
    }
  6. Compact on your terms

    Run /compact with a focus before a long new task, for example /compact focus on the auth bug fix. To make the automatic pass run earlier, set the window with /autocompact, for example /autocompact 500k (v2.1.221 or later). If you keep auto-compact off, you have to compact before the window fills.

  7. Keep the window lean

    Disable unused MCP servers with /mcp disable <name>, trim long CLAUDE.md files, and /clear between unrelated tasks.

That example is from the status line docs. On Codex, the CLI's /status shows remaining context and /statusline can put it in the footer (Codex docs).

What the fix doesn't cover

Two limits to know first

A gauge warns you; it doesn't stop the failure. Compaction can still error on a cause outside your control, such as a model or network problem. Every compaction is a summary. Whatever the summary leaves out, including tool output that was cleared earlier, is no longer in the agent's context, even though the transcript file still holds it.

How Axiom Lift helps (partly)

Plainly: Axiom Lift does not stop compaction failing, and it doesn't add a context meter. The steps above are the fix for those.

It helps with the aftermath. Axiom is a small helper on your computer that reads the session files Claude Code, Codex and OpenCode already keep, and saves every prompt, decision, requirement and result to your account as you work. It never edits those files. When your tool compacts, Axiom has already saved every line before that and captures again at that moment. The full conversation stays in your account, searchable, with the decisions filed.

So when a session dies at the limit, the next one doesn't start from nothing: over a read-only MCP connection it can ask Axiom what was decided and why, and gets back the few lines that are true now rather than the whole transcript.

As you work, every line is saved to your account; at the limit compaction fails and the session is stuck; the next session asks Axiom what was decided
Axiom doesn't fix the error. It keeps what came before it, so the next session can carry on.

The free fix

  • Update, read the error, resume, compact by hand
  • /context and a status line show the window
  • The transcript sits on disk as one JSONL file per session
  • A new session gets back CLAUDE.md and memory files, not the conversation

With Axiom

  • Doesn't prevent the error or show the meter: use the steps above
  • Saves every line before compaction, and again at compaction
  • Decisions, fixes and requirements filed and searchable in your account
  • The next session asks over MCP what was decided, in Claude Code, Codex or OpenCode

Free covers one computer and lets your AI reach the last six months (up to 1 GB). Mac, with Linux and Windows in beta; needs Python 3; axiom uninstall removes it.

Keep what the session knew, even when it dies

One command in the terminal where you use Claude Code, Codex or OpenCode. Free, no card.

Try it free →

Claude, Codex and OpenCode are trademarks of their owners; Axiom works alongside them and is not affiliated.