ByteCosts
stacking-token-saving-tools.mdx

AI Coding Agents

Stacking Token Saving Tools for Coding Agents

When stacking token saving tools, start with the layer that handles your largest avoidable cost and test it by itself. Add one tool at a time, trace which copy of the data each tool sees, and keep a layer only if it lowers cost per accepted task or offers another benefit you can measure.

Map the stack by what each tool sees

TokenWar is a useful example of the difference between a bundle and a measurement. Its README assigns compact responses to Caveman, shell filtering to RTK, heavy context to context-mode, session memory to claude-mem, and smaller code to Ponytail. It has separate roles for provider payloads and repository exploration. These slots describe what TokenWar intends each component to do. They do not establish that every current install stays within its slot. Caveman’s own README describes a proxy as well as a voice skill, while RTK documents optional pipelines and a provider proxy in addition to its shell filter. TokenWar · Caveman · RTK

SurfaceFirst candidate to evaluateWhere overlap can appear
Command invocation and outputRTK’s default shell filtercontext-mode can redirect certain commands or substitute large tool outputs
Local data and indexed tool resultscontext-mode sandbox and searchA prior filter may already have removed information the index would otherwise hold
Provider-bound messagesHeadroom proxy or Caveman compressionBoth can touch tool results, and both see only what the host actually sends
Response prose and implementation behaviorCaveman voice or PonytailTerse instructions, workflow rules, and other output-shaping settings can all influence the same generation
Cross-session contextclaude-memOther memory or resume mechanisms may supply the same facts and add retrieval overhead

Inventory active features by installation and scope. Record which settings are global, which belong to the project, and which only take effect when you launch a wrapper. Check the request path in the host you use. A successful registration tells you where a plugin is configured. A sample task tells you which features actually run. Proxy, hook, and MCP cost layers

Trace one tool result before changing hook order

Take a failing test command as a fixture. Keep its raw result, exit status, and expected diagnosis. First identify whether the host runs the original command or a rewritten one. Then inspect what it receives from that command, what enters conversation history, and what the provider-bound request contains. The cheapest place to act is often where you can prevent unwanted output from entering the history in the first place. The best place to retain exact evidence is wherever you still have a complete copy.

A default RTK configuration can rewrite a supported shell command and pass its filtered output to the host. context-mode documents a pre-tool path that redirects some large reads and commands to its own tools, as well as a path that indexes large results. The order in which host hooks run determines what each component sees. If a command goes through a context-mode tool, check whether it still passes through the RTK integration in your setup. If a filtered result reaches the index, determine whether the raw data exists in a separate recovery store. Tool names in settings alone cannot establish either behavior. RTK · context-mode

Once the host prepares a request, a proxy such as Headroom can compress the outgoing messages. Headroom documents storing originals through CCR and making them available through a retrieval tool. An original in that store means the text Headroom received. If an earlier tool passed it a shell summary, that summary is the input to Headroom’s recovery path. Test retrieval by asking the agent for a diagnostic that appeared in the raw command output but was omitted from the short result. Check which tool supplies it and whether the agent can then identify the failing assertion. Headroom

Count double compression against what remains

Suppose the raw log includes a long run of passing tests, a failure, and file locations. A shell filter collapses the passes and retains the assertion. A proxy may then collapse repeated fields in the returned payload. Its opportunity is the smaller payload it actually received. Adding the two tools’ savings estimates would count some removed text twice if both estimates compared against the raw log.

Track a baseline with neither tool, a run with the shell filter, and a run with the same filter plus the proxy. If you are deciding which one to keep, add a proxy-only run. Record bytes or local token estimates at the boundaries to diagnose what changed. Compare provider usage and task acceptance to decide whether the change paid off. The difference between filter-only and filter-plus-proxy is the incremental result for that order. A proxy-only run answers a different question and can expose overlap you would miss if you only compared the full stack against the baseline.

Recovery traffic also belongs in the comparison. The model may ask for a wider excerpt, call a retrieval tool, or run the command again. These actions can add input and generated tool arguments, and can delay the final result. Make a missing-detail case part of the trial. Check that the recovery response reaches the model with enough detail to finish the task. An open Headroom issue title describes CCR recovery JSON being offloaded again through a Codex wrapper. Treat that as a reason to test the path you actually use. Headroom recovery report

Check cache reuse on later turns

The first tool result tells you whether the amount of content changed. The next turn tells you whether the compressed request still reused the preceding prompt prefix. If the second tool rewrites older messages or modifies system instructions, it can shift input from a lower-priced cache read bucket toward fresh input or cache writes. Record each usage bucket separately and include output and retries. Compare the same sequence of turns and starting cache conditions. Context compression versus prompt caching

RTK’s README describes the default filter as operating before output enters the conversation. Headroom’s README describes a live zone for fresh content that keeps the frozen prefix byte-identical. These design descriptions make different promises at different points in the request flow. Test them in combination, especially if you also enable a feature that folds old history, changes the tool list, or adds memory. If you change the hook order, cache behavior is part of the retest. RTK · Headroom · Caveman

Give prose and workflow instructions distinct jobs

The Caveman voice specifies how the agent answers. Ponytail steers implementation toward existing code and smaller changes and includes rules about verification and reporting. They can affect the same output through different instructions. A short response is valuable when it still reports the relevant work and uncertainty. A patch with fewer lines is valuable when it still handles the required cases. Test each feature against its own criterion before trying them together. Ponytail · Caveman

Use an explicit answer rubric that preserves requirements such as citing edited files, reporting the exact error, and identifying skipped verification. Reuse it on a task where the agent makes a change and a task where it only explains what happened. Compare a concise instruction in the prompt, the chosen skill, and the combined rules if you want both. Count startup instructions and any reinjection on later turns, even when the user interface displays only the final message. If the combined rules omit an item your rubric requires, revise the conflicting rule or use the version that passed alone. A closed Ponytail issue asks about combining the tools. Its title establishes that someone raised the question. Your own test establishes how your active rules interact. Ponytail combination question

Measure memory across the sessions that reuse it

claude-mem documents an observer that generates observations from tool activity and injects an index into later sessions. Its recall tools can then fetch details. That gives the stack another opportunity to cut repeated discovery, and another source of model calls, prompt input, and searches to account for. context-mode’s local index and continuity workflow serve a different immediate purpose, but a resumed session can still recover facts the observer has already summarized. Compare the actual recovered facts before loading both paths. claude-mem · context-mode

Run related tasks that start in separate sessions. Record how much it costs to create the notes, what the new session gets automatically, and which details are fetched. A trial that ends after the first session can measure capture cost. It needs a subsequent session to measure whether that spending avoids rereading. Choose a follow-up question about a prior design decision and check that the recalled answer matches the repository state or the earlier decision record. Drop duplicate startup context when it adds tokens without changing what the agent can do.

Add one layer and decide whether to keep it

Start with a representative task set, such as a failing test, a change that needs file navigation, and a follow-up that depends on earlier work. Keep the repository revision, agent, model, prompt, and acceptance checks fixed. Use a clean session for each run and note when you intentionally start warm. Record the version and enabled mode for every tool. A capability in the README only becomes part of the measurement after you confirm it reached the task.

  • Baseline. Save accepted and rejected outcomes, elapsed time, provider usage, and any auxiliary model spend. Include recovery and retries in the task total.
  • First layer. Enable the feature that addresses the largest avoidable source of cost. Confirm that it intercepted the expected input or changed the expected behavior.
  • Next layer. Keep the first feature fixed and add one more. Compare incremental usage and verify that the agent can still recover exact data. Repeat for each candidate feature.
  • Decision. Keep the combination that passes the checks and has a lower cost per accepted task or a documented operational benefit. Record the settings you can restore if a host update changes the behavior.

Before the trial, decide which tool owns each piece of the workflow. If RTK already handles test output and the remaining issue is bulk in provider-bound file reads, configure the proxy for the latter where its supported settings allow. If the proxy also transforms a recovery response, test a direct read with the proxy feature disabled. Keep a trace of the input and output at each boundary for the failing case. That makes it possible to remove the smallest responsible configuration change when the combined setup fails.

Run an ordinary short task as a control. Additional schemas, injected rules, and helper calls can consume more than the stack saves when there is little output to trim. A good result on verbose builds can justify using the stack for those runs even if plain sessions are cheaper for small edits.

If you use TokenWar, its README says a bare install adds the shell integration and none of the managed tools. It also documents reporting native telemetry when available, with estimates labeled and unavailable data marked accordingly. Use that telemetry to identify what the bundle touched. Make the final decision from usage and outcomes for the entire task. If your bottleneck changes, return to the baseline before expanding the stack. How to measure coding agent token savings · Choose a token saving stack

Sources

Interactive report

  • Do Token Savers Actually Save?: RTK reported saving 74.7% of the tokens on the commands it touched. In tokbench’s pilot, the RTK run still used 27% more provider-billed input than the unmodified run. The comparison shows why a tool’s savings counter and the provider’s meter can move in opposite directions.

How this note was produced

Drafted with AI assistance from committed ByteCosts pricing snapshots and deterministic cost formulas. Figures are grounded in the linked sources (last updated 2026-11-30). Read our editorial & automation policy, inspect the methodology, or report a discrepancy.

Stacking Token Saving Tools for Coding Agents. ByteCosts. Updated 2026-11-30. https://bytecosts.com/blog/stacking-token-saving-tools/

Sources