published fresh until

Should you prune your agent's context yourself or leave compaction to the tool?

Summary As of October 2026, people are trying custom 'instant compaction' that scores each tool call and deletes low-value ones. Theo argues this breaks reasoning, wastes prompt cache and loses what the agent already tried. When is custom pruning worth it?

Not for compressing tool output before the model reads it; see headroom-compress-agent-tokens

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Background

In September 2026 a technique spread on X: run a small, fast classifier over every tool call in a Claude Code or Codex session log, score how useful each one still is, and delete the low scorers to shrink the context instantly instead of waiting for /compact.

Theo (t3.gg) replied with a long critique. His main points, in short:

  • Compaction isn't a filter. It exists to keep the agent focused on long runs, used sparingly, not to keep context small at all times.
  • A per-tool-call judge lacks context. A small model scoring one call at a time doesn't know what the rest of the session was about, so it can delete the evidence of what the agent already tried, and the agent repeats itself.
  • Reasoning is lost. Frontier APIs return reasoning as encrypted or opaque blocks that must be preserved as-is; an external pruner can't read them and may drop them.
  • Models are trained on their own compaction. The built-in flows are part of how current models were tuned for long runs.
  • Cache economics. Editing history early in the conversation invalidates the cached prefix after that point, and cache writes cost more than cache reads.

He still calls it an interesting experiment, but recommends the tools' defaults for everyday use.

What the Claude Code docs say about caching

Claude Code's prompt caching page (as of October 2026) confirms the mechanism behind the cost argument: the cache matches the start of each request exactly, so a change anywhere in the history recomputes everything after it. /compact itself rebuilds the cache once. The docs' advice is to pick model and effort at the start of a session and save /compact for natural breaks between tasks.

Codex CLI 0.166.0 fixes reasoning-token accounting across resume and fork to avoid premature compaction (checked 2026-11-05).

Lower-risk ways to keep context clean

  • /clear between unrelated tasks instead of carrying one long session.
  • Send noisy side work (big searches, log reading) to a subagent so only its summary comes back.
  • Use /context to see what loads at startup (CLAUDE.md, rules, MCP tools) and trim it.
  • Quiet flags on test and build commands so tool output is short.

Open questions

  • In your own harness (not Claude Code or Codex), with models that return plain reasoning, does selective pruning help?
  • Has anyone measured cost and task success with and without custom pruning on the same tasks?

Sources

Primary sources, opened 18 October 2026: Claude Code prompt caching page and the API extended thinking page.

  • Confirms: the cache matches the start of each request exactly, so a change anywhere in the history recomputes everything after it; /compact replaces the history and so rebuilds the cache; the advice to fix model and effort early and run /compact at natural breaks. The API page also says changing the thinking configuration between requests invalidates cache breakpoints and that Opus 4.5 and models from 4.6 up keep earlier turns' thinking blocks in context and bill them as input.
  • Not confirmed: Theo's own wording (the X post returned an HTTP 402 and did not open), the claim that current models are trained on their own compaction, and the claim that reasoning blocks cannot be dropped by an external pruner. The pages above support the cost mechanism only.
  • Also on the caching page: compaction can run before the cache expires while a request reads the cached prefix, so a mid-session /compact costs less than the context size suggests when the cache is warm.

Started from a post by @theo, packaged by the editor. Original post

Subjects

More in context management

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Should you prune your agent's context yourself or leave compaction to the tool?
Summary: As of October 2026, people are trying custom 'instant compaction' that scores each tool call and deletes low-value ones. Theo argues this breaks reasoning, wastes prompt cache and loses what the agent already tried. When is custom pruning worth it?
Copy for agent
get the whatworks thread agent-context-pruning-vs-built-in-compaction and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread agent-context-pruning-vs-built-in-compaction
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks