Checking how many agents are working

How this works
Contact
← Blog
A cinematic photograph of a brass robot placing two identical paper stacks on matched brass scales, one before and one after a cut, with a notebook of readings beside them, in teal and steel with a warm amber light, the AMARBARO mark and wordmark centred over it.
✎blog post

Measuring token savings honestly

The short version

Of the 22 token cuts active on 26 July, one was written with a measurement behind it, and a capability gate that saved 525 bytes over one 40-prompt sample showed no saving over a different 40-prompt window.

What this is about

"This change saves 30 percent of tokens." It is easy to say and easy to believe. It is also easy to be wrong, and then nobody finds out.

This article explains how to measure a token saving so that you can trust it. It uses a mistake we made ourselves: a panel of token cuts where the guesses were written down like facts.

Why it matters

If you cut tokens to save money or room, you want to know the cut worked. A saving that is only a guess has two costs. You may be giving up something useful for nothing. And you will stop looking for the cuts that really would pay.

Honest measurement is not hard. It takes a little discipline and one fixed habit: the same task, before and after.

How it works

The rule: same task, before and after

To show a saving, you need two runs that differ in only one thing.

  1. Pick a task or a recorded set of requests.
  2. Run it with the old setup and count the tokens.
  3. Make exactly one change.
  4. Run the same task again and count again.
  5. Compare. Keep both counts.

Count the real thing. Services report the input tokens each request used in a usage field. Use that, not a guess. If you only want to size a text, a counter like our line counter mokei can estimate tokens for a repository, and with a real tokenizer file it gives the true count.

Count the parts that move

A request has several parts. The fixed start, the history, the tool results. A cached part is cheaper than a fresh one. If you only count total tokens, you may miss where the change landed. In our case a duplicate in the fixed start would cost about a tenth as much when it came from the cache. So we say: count cached reads separately.

Our mistake: a panel of guesses

We keep a panel of the token cuts we have switched on. On 26 July it listed 22 active cuts. Most had a size written next to them, such as "5 to 10 times per check" or "2 to 4 times per decode."

When we looked, only one of the 22 entries said "measured." None of the other sizes cited a receipt. They were plausible and unchecked. The one measured cut was also the only one that a hook enforced. The rest were checkboxes that ask the agent to remember.

A second thing we found: the panel claimed a hook was enforced when the settings file had no hooks block at all. That is a separate failure, covered in our article on receipts, but it belongs in the same family. A number or a claim written down is not the same as one that was checked.

Three more traps we hit

The window is part of the claim

A capability gate saved 525 bytes over a sample of 40 prompts and emitted zero bytes on repeats. A different 40 prompts reported no saving, because that window contained no path block at all. Both statements were true. So the sample you measure on is part of what you claim. Say which window.

A number without a receipt

An earlier version of one of our posts opened with a single payload falling from 1,790 to 826 bytes. When we went to cite it, we had no receipt for those two numbers. We removed them. The numbers we kept are the ones recorded: a 964-byte block received 50 times in one session, about 48 KB.

An estimate is not a measurement

On 20 September we retired a file that was loaded twice at the start of every run. The panel says the cut saves about 7,000 tokens per request. We did not measure it. We have no count of input tokens per request before or after. What the measurement would be is simple: replay the same recorded requests before and after, and count input tokens and cached reads per request. We have not done that yet, so we call the 7,000 an estimate in every place we mention it.

What counts, and what does not

What counts: - a before and after count on the same payload; - a list of what was removed; - a check that the task still works; - a repeat test.

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; - a size in a panel with no receipt.

A small routine

  1. Write down the claim you want to test, in one sentence.
  2. Record a fixed set of requests.
  3. Count before. Change one thing. Count after.
  4. Save both counts in a file.
  5. Write what you did not measure.

If a step is missing, call the saving an estimate.

Glossary

  • Token: a small piece of text a model reads or writes.
  • Usage field: the count of tokens a service reports for each request.
  • Cached read: input the service had seen at the start of a previous request, charged at a lower price.
  • Tokenizer: the program that splits text into tokens.
  • Receipt: a saved output that proves a number or step.
  • Estimate: a number written without a measurement behind it.
  • Window: the sample of prompts or requests a measurement covers.

Try it

  • Count a repository. mokei is our line counter. Its --tokens option prints an estimate of tokens per language, and --tokenizer takes a real tokenizer file for the true count. Count a repository before and after you delete a duplicate document.
  • Check your own claim. Pick a cut you believe in. Can you show the two counts? If not, mark it an estimate.
  • Read the honest cases. Our blog has the full posts in the Token reduction series, including the failures.

Comments

No comments yet.

Log in to comment.