What this is about
In the last article on tokens we saw where an agent spends them. This one is about what to do. The idea is simple: the cheapest token is the one that is never sent.
We have four ways to cut, from easy to harder. Each comes with a real case and an honest note about what we could prove.
Why it matters
Tokens are money, time and room. Cutting text after it is sent can help, but it is the second best option. The text still travelled, and a summary of it still costs something. If the text never enters the request, it costs nothing.
A second reason is trust. When you cut at the source, it is easy to check: the same payload, before and after, with a count. When you compress somewhere in the middle, it is easy to fool yourself.
How it works
Cut 1: remove the duplicate
Look for text that arrives twice.
On 20 September we retired a file that every Claude Code run under our home directory loaded twice. The panel that tracks our cuts records the saving as "about 7k tokens per request." Here is the honest part: we have not measured that number. We have no count of input tokens per request before the cut or after it. We are reporting the panel's estimate, not a result.
What we can say is smaller and still useful. In one count, 40 skill descriptions came to about 4,600 tokens. A 7,000 token duplicate would be larger than that whole list. And a cached token still takes room in the context window. Caching lowers the price. It does not give the room back.
Cut 2: shorten the fixed start
Every request begins with the same standing text. Anything long there is paid for on every turn.
Our skill list was one example. The listing for one of our projects cost 18.6 KB per turn. We grouped 60 linked skills into 12 hubs, each hub pointing to its member skills by real path. The listing fell to 5.5 KB, a drop of 70 percent. We then checked that routing still worked: the model picked the right hub from the listing alone, 22 of 22 on one set and 8 of 8 on a held-out set.
The point is the check. A shorter start is only a saving if the agent still finds what it needs.
Cut 3: stop the repeat where it starts
One path-hint block in one of our hook messages was 964 bytes. A single real session received it 50 times, about 48 KB. We first built a filter that stripped the repeats before they reached the model. Later, we retired the filter and cut the senders at the source instead, which is the rule this series keeps coming back to.
A related mistake taught us a boundary. A wrapper that only passes messages along started removing repeated ones. It saved bytes but changed what was sent, and we reverted it. The piece that owns a message may drop its own repeats. A middleman must pass things through unchanged.
Cut 4: send text, not a picture of text
A screenshot of 900 by 300 pixels cost 363 vision tokens as a picture. The text in it cost 27. The cut here is a hook that denies a read of a picture that contains text and hands back the recognised text instead. The words still reach the model.
A smaller image file does not help. Pictures are billed by pixel size, not file size, so changing the file type changes nothing.
What counts as a saving
We keep a short checklist.
What counts: - a before and after receipt from the same payload; - a list of what was removed; - a check that the task contract is still there; - a repeat test against the thing that emits the text.
What does not count: - a smaller prompt made by changing the task; - a cache hit reported without the input bytes; - a saving measured on a window that never contained the target block.
Where ctxd fits
Our context proxy ctxd works on the second half of the problem. It cannot stop a file from being opened. But when a long chat grows past its window, it folds the oldest part into a summary and keeps the original on disk. The next article in this series covers that.
Glossary
- Prefix: the fixed start of every request.
- Payload: the text sent in one request.
- Hook: a small program that runs at a set moment and can change or block what happens.
- Source: the program that creates a piece of text, as opposed to one that merely passes it on.
- Receipt: a saved output that anyone can open to check a claim.
- Vision token: a token charged for an image, based on its pixel size.
- Held-out set: test questions not used while tuning.
Try it
- Fold old history. ctxd is our context proxy. Its repository has the code and the gate scripts that test it. Read the README for how it decides when to fold.
- Count first. Before you cut anything in your own setup, count the tokens of one request. Our counter mokei can estimate tokens for a repository.
- Find one duplicate. Look at the standing instructions you give your assistant. Is any rule written twice, in two files? Remove one copy and note the date.

Commenti
Ancora nessun commento.
Accedi per commentare.