AgentReceipt

What compaction costs, and when it is worth it

When a session fills its context, Claude Code summarizes it and rebuilds the context. Both the summary and the rebuilt prefix are paid for. Here is how to see it on a receipt.

Auto-compaction triggers near the context limit: the model writes a summary of the conversation (output tokens), and the next turn starts from a new, shorter context, which has to be written to cache again.

Compaction is not waste in itself; it is what lets a long task continue. It is a signal that the session has grown beyond one task, and the turns before it were each carrying a very large context.

How to fix it

  • One task per session: /clear when the task changes.
  • Keep tool output small so the context grows slowly.
  • Split migrations into per-module sessions.

See it in your own session

Drop the session file below. Every step this applies to is flagged on the receipt with what it cost and what fixing it would have saved.

Itemize your own session

Drop a Claude Code or Codex log. It is parsed in your browser, and you get your real numbers instead of a model.

Drop a session log here

Claude Code ~/.claude/projects/…/*.jsonl, a Codex rollout ~/.codex/sessions/…/rollout-*.jsonl, or the claude-code-action execution file.

Parsed in your browser. Your prompts and code never leave this tab.