128 ways to spend fewer tokens
The 22 Beginner tips are free to read. The 106 advanced tactics unlock with Pro — plus a fresh tip in your inbox every morning.
Drop the Screenshot Once the Model Has Read It
Images, PDFs, and attachments are charged as tokens and re-sent every turn in a multimodal thread. After the model has described or transcribed one, you usually don't need to keep sending the pixels.
Paste the Function, Not the Whole File
Most coding questions need 20-40 lines, not your 800-line file. Send the relevant slice plus a one-line note about the rest, and your input shrinks dramatically without hurting the answer.
Start a New Chat When the Topic Changes
Chat apps re-send your whole conversation with every message. When you switch tasks, the old turns become dead weight you keep paying to re-transmit — even with caching discounts.
Run /context and Strip MCP Tool Schemas You Never Call
Every connected MCP server injects its full tool schemas into context on every single turn, whether you call those tools or not. Run /context to see the bloat, then disable idle servers and trim tools you never use.
Compact Context by Deleting Dead Weight, Not Summarizing It
Before a turn, run a mechanical pass that deletes low-signal tokens (boilerplate, repeated formatting, verbose metadata) while leaving every surviving sentence character-for-character identical. You cut the re-billed context without the paraphrase errors a summary introduces.
Convert Fetched Pages to Markdown Before They Hit the Agent's Context
Browse and research agents that feed raw HTML into context pay for tag soup, scripts, and styling the model never uses. Strip each fetched page to clean Markdown at the tool-result boundary first.
Load Skill Names Up Front, Bodies Only When Triggered
A big library of specialized agent instructions billed on every turn is mostly dead weight. Structure each capability as a Skill so only its name and one-line description load at startup, and the heavy instruction body is read into context only when that skill actually fires.
Prune Bulky Tool Results Once You've Used Them
Tool and function-call outputs are the heaviest, most disposable thing in an agent transcript. Once the model has extracted what it needs, replace the raw result with a one-line stub before the next turn.
Compress Long Threads with a Rolling Summary
Instead of dragging a 40-turn thread forward, periodically have the model write a compact state summary, then continue from that.
Abort the Agent the Moment It Stops Making Progress
Count caps, task budgets, and request de-duplication all miss the same failure: an agent that keeps issuing the same tool call, or advances a turn with no state change, and re-sends the full transcript every time. Add a duplicate/no-progress detector that halts the run the instant a loop is detected, so you stop paying quadratic re-prefill on a trajectory that cannot converge.
Annotate Context as Dependency-Linked Episodes, Then Evict Graduated
Both at-budget and fixed-interval compaction throw away context blindly. Instead have the agent tag its trajectory as typed episodes with explicit dependency links, then deterministically evict whole episodes only when nothing still-live depends on them — a graduated lifecycle that stays in budget over arbitrarily long runs.
Let the API compact the conversation server-side (compact-2026-01-12)
On long agentic Claude runs, every turn re-bills the entire growing history. Anthropic's server-side compaction auto-summarizes the conversation into a compaction block at a token trigger, then drops all blocks before it on the next request so you pay for the summary plus recent turns instead of the full transcript.
Evict Stale Thinking Blocks on Long Reasoning Agents Without Torching Your Cache
On Opus 4.5+/Sonnet 4.6+, extended-thinking blocks from every prior turn are kept in context by default — dead reasoning you re-pay for on every turn of a long agent loop. The clear_thinking strategy evicts them; batch the clears so the cache re-write pays off.
Compress Tool Output Only If the Agent Would Take the Same Next Action
Shrinking tool observations is only safe if the agent behaves identically on the smaller version. Accept a compressed observation only when it induces the exact same next action as the raw one, and reject it otherwise.
Update Codex CLI So the Skill Catalog Budgets Itself Instead of Eating Your Window
Every skill and plugin you install adds a metadata row — name, description, and an absolute host path — that Codex concatenates into context on every turn, whether or not the skill ever fires. As the library grows, that catalog silently eats the model's window on long runs. Codex CLI 0.146.0 (July 29 2026) treats the catalog as a budgeted resource: it compacts host skill paths under metadata pressure and warns when the catalog exceeds its context budget. Update, then heed the warning and tune your loaded set instead of installing every skill wholesale.
Put a Content-Aware Compression Proxy Between Your Agent and the Model
Drop a compression layer on the agent-to-model boundary that detects what each blob is (JSON, code, prose) and routes it to a format-specialized lossy compressor, while handing the model a tool to restore any blob to the original on demand. It shapes input tokens before they hit the window, uniformly, regardless of which framework produced them.
Delta-Debug Your Skill Definitions Down to What Actually Fires
Hand-written Skill / AGENTS.md files carry two kinds of fat: bloated routing descriptions that load on every turn, and bodies stuffed with background and examples the model rarely needs. Run an automated pass that delta-debugs each routing line to the minimum that still triggers correctly, then splits the body into core rules vs on-demand reference files.
Keep Working State in a File, Not in the Conversation
On long tasks, let the model write its plan, findings, and decisions to an external scratchpad and re-read only the slice it needs, instead of accumulating all of it as ever-growing conversation history.
Fork the Session Instead of Re-Spawning a Sub-Agent That Starts From Zero
On a multi-step agent job that works over one shared codebase, spawning a fresh sub-agent per step makes each one re-find, re-search, and re-read everything from scratch at full input price. When a phase builds on the last, fork the session so it inherits that context and skips the redundant re-exploration.
Let the agent decide when to compact, not a token threshold
Threshold-triggered compaction fires mid-derivation and throws away partial results you already paid to compute. Give the agent a compaction tool plus a rubric so it compacts on sub-task completion instead of at an arbitrary token line.
Compress MCP tool schemas with a lazy-loading proxy
When you wire up several MCP servers, the full schema for every tool they expose rides along on every turn — a fixed tax that dwarfs your actual prompt. Put a compression proxy in front that exposes just two tools and lets the model fetch a tool's full schema only when it actually needs it.
Turn On OpenAI's Server-Side Compaction for Hour-Long Agent Runs
A multi-hour OpenAI agent re-sends its entire swelling transcript on every turn. Set a compaction threshold and the Responses API summarizes old turns server-side into one encrypted item that carries state forward in far fewer tokens.
Render Bulky Static Context as an Image and Pay the Per-Image Token Cap
Text input is billed per token with no ceiling; an image is billed by pixel area and hits a hard per-image cap no matter how many characters it depicts. For genuinely huge, static, lossy-tolerant blocks, re-rendering them as a dense image changes the encoding you're billed under without removing anything from the model's view.
Set reasoning.context to all_turns So Your Agent Stops Re-Deriving Chains of Thought You Already Bought
On the Responses API, whether earlier turns' reasoning items get rendered into the next sample is the model's default unless you say otherwise — so a multi-turn agent can silently re-derive conclusions it already reached and billed you for. `reasoning.context: "all_turns"` retains them. Switch back to `current_turn` the moment that reasoning goes stale.
Rebuild the prompt fresh each turn, don't append the transcript
In a long agent loop, appending every observation and action to a running transcript makes each turn cost more than the last. Instead, assemble a fresh, fixed-size user message per decision by typed retrieval from an external store, so prompt size stays constant no matter how long the run gets.
Query Huge Inputs as a Code Variable, Not a Prompt (Recursive Language Models)
Instead of pasting a giant corpus into the context window, load it as a variable in a code sandbox and let the model write code to chunk it and fire cheap recursive LM calls over the pieces — so the root model orchestrates the answer without ever ingesting the full text.
Retrieve Tools by Relevance Each Turn Instead of Loading the Whole Catalog
Keep the full tool/skill catalog out of the context window in a local index and, each turn, use keyword + semantic retrieval to inject only the handful of tool schemas relevant to the current step.
Self-GC: a side-channel planner that folds, masks, or prunes each context object
Most context trimming is a single binary rule: keep the object or drop it. Self-GC turns every user turn and tool span into an indexed object, then runs a separate planner that picks per object among three graded actions - fold (move the exact payload to a sidecar and leave a recovery pointer), mask (keep the structural boundaries but elide the low-signal middle), or prune (drop it, with no recovery guarantee) - so most trimming stays recoverable and only genuine dead-ends are dropped for good.
Let the API Auto-Clear Stale Tool Results Mid-Run
In long agent loops, every old file dump and search result gets re-billed as input on each new turn. Anthropic's context-editing beta makes the API itself swap stale tool results for short placeholders once you cross a token trigger, so you stop re-paying for context the agent no longer needs.
Build a Sliding Window with a Cached, Stable Prefix
For API apps, cap history at the last N turns and put unchanging instructions first so prompt caching can discount the prefix.
Store Each Inter-Agent Message Once, Then Reference It
In multi-agent orchestrator loops, a single inter-agent message body can get serialized into two places at once: the replayed conversation history AND the tool-result blocks. You then re-pay input tokens for the same payload twice on every replayed turn, and the waste compounds as the thread grows. Store each message once and reference it by ID so the duplicate disappears — a structural fix, not an after-the-fact prune (shipped in Claude Code 2.1.212).
Strip Credentials from Tool Schemas and Inject Them at Execution Time
Remove oauth_token, api_key, and client_id parameters from every tool's JSON schema and resolve them at call time from a vault keyed on connected_account_id, so auth fields never occupy your context window on any turn.
Prune tool output by relevance, not by age
A sliding window evicts old tool results and keeps recent ones — but "recent" and "relevant" are different things. Score each tool result against the CURRENT task with a small learned scorer and drop the low-scoring blobs regardless of age, keeping the one critical result from twelve turns ago that a window would have thrown away.
Validate the Summary Before You Drop the Old Context, Not After
Naive summarize-and-drop compaction saves tokens right up until the summary silently loses a load-bearing fact and the agent falls off an accuracy cliff. Add a validation gate: before evicting the old turns, verify the fresh summary actually preserves the must-keep facts. Only drop once the check passes.
Like what you see?
Get a fresh one in your inbox — weekly free, daily on Pro.