DEV Community

Cover image for How to cut your AI agent's input tokens: what worked, what failed, and a bench to measure yours

How to cut your AI agent's input tokens: what worked, what failed, and a bench to measure yours

Anis Meziani on October 28, 2026

Before every single thought, our BI agent re-read 17,000 tokens of instructions and tool manuals. Then the whole conversation. Then every table it...
Collapse
 
max_quimby profile image
Max Quimby •

The "fewer calls beats smaller calls" lesson is the one I keep relearning. We spent a while shaving tool-result size and got modest wins, then realized a single turn that made the model call out five times was costing more than all the context we'd trimmed — collapsing that to one call dwarfed everything else.

One trap worth flagging on the pruning side: when you shorten or drop old tool results, the agent sometimes just re-calls the tool to recover the data it threw away, so the "saving" shows up as a new call two turns later. We only caught it because total tokens per conversation barely moved even though per-call tokens dropped.

On caching — the deterministic ordering point is huge and underrated. A prefix that's 98% reusable vs 11% is the same tokens on paper but a completely different bill. How are you deciding which quality regressions are acceptable? Your note that the bench missed a failure entirely is the part that would keep me up at night.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Thanks Max, the re-call trap is a real gap for us. Our bench replays a scripted model, so it never re-fetches by construction, and our real runs were single questions, not long conversations. Your "per-call down, total flat" check is exactly what we haven't run on real traffic yet.

Up for an issue on a re-fetch rate (same tool, same arguments, after compaction)? Your check as the spec, credited to you.

On regressions: none accepted on the bench, one failed check rejects the cut. The missed failure keeps me up too: the fix is making the forecast scenario call the real engine instead of a canned answer.

How did you fix the re-calls: more fields kept, or summaries instead of truncation?

Collapse
 
kevinhall profile image
Kevin Hall •

Your 80% on tools matches what I measured on a hosted MCP server: per Actor tool, the output schema inferred from sample rows was the larger half in 9 of 20 tools, up to about 32K tokens in one. If any of your 36 declarations carry a generated output schema, I would check that half before the descriptions.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Good catch, and it matches what we found, in another form. Our declarations go out in the OpenAI format through LiteLLM: name, description, input parameters, no output schema field. The output half hid in the docstrings instead: the "Returns" sections, which we cut along with the unused tools. 32K for one tool is wild. Was that schema actually helping the model, or just inferred by default?

Collapse
 
kevinhall profile image
Kevin Hall •

Inferred by default, the server builds it from sample rows. Whether the model gets better calls from it I have not measured, so I cannot say it earns its tokens.

Thread Thread
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Cheap test: same tasks with and without the schema, compare failed calls next to tokens. If nothing moves, 32K is pure tax.

Collapse
 
mmarchand04 profile image
Mathis Marchand •

This is a brilliant and much-needed breakdown of token optimization for AI agents in production!
Providing a 7-point checklist alongside an open-source bench is incredibly valuable for the community.
Thanks for sharing this transparent field report on your successes and failures to help us save time and money.

Collapse
 
glenallen profile image
Glen Allen •

One important takeaway is that optimizing AI agents isn't just about reducing prompt length; it's about managing context and tool usage intelligently. Removing unused tool definitions, compacting older tool results, and reducing unnecessary model calls can significantly improve efficiency without sacrificing answer quality. At IT Path Solutions, we see evaluation and real-world testing as essential parts of building reliable AI agents. Measuring token consumption alongside response accuracy helps teams make optimizations that deliver genuine cost savings while preserving performance.

Collapse
 
alexshev profile image
Alex Shev •

Offline replay is a good starting point, but the live-run difference matters. Comparing token savings alongside task success and retrieval misses would show when a shorter context becomes too lossy.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Agreed. The bench already pairs savings with quality: every answer is checked for the right facts, and for numbers that don't appear in what the model actually saw. That check is what told us compacting the current turn was too lossy (4 scenarios failed).

On live runs, we only checked answers by hand so far. Tracking success rate and re-fetches next to tokens there is the next step. How do you measure retrieval misses on your side?

Collapse
 
alexshev profile image
Alex Shev •

For retrieval misses I track expected support IDs per scenario, then measure whether any supporting chunk reached the model at k. That gives retrieval recall separately from answer quality; traces also reveal when the right chunk arrived but was ignored.

Thread Thread
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Nice, that's close to our facts check: each scenario lists the facts the answer needs, and we check they reached the model, separately from the answer. "Arrived but ignored" is the case we don't separate yet. Up for opening an issue on it? github.com/apowerb/apowerb/issues

Thread Thread
 
alexshev profile image
Alex Shev •

That split would make the benchmark much more diagnostic. I would model three states: support was retrieved, support was selected into context, and support was used in the answer. A miss at each stage points to a different fix, so it is worth keeping them separate.

Thread Thread
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Agreed, three states is the right model. Today our facts check covers the second (in context), and the grounding check part of the third. Retrieved vs selected isn't separated at all.

I opened an issue with your three states as the spec, credited to you: github.com/apowerb/apowerb/issues/511

Feel free to take it from there, comments or a PR.

Collapse
 
paul_irolla_6b5ae261d0224 profile image
Paul Irolla •

Splitting the fixed prefix from the work is the step many benches skip: those tokens are re-sent with every request before any task starts. Did they come mostly from tool schemas, or from the system prompt?

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Thanks Paul. Mostly the tool schemas. On the first call, before any cut, the tool declarations were 52,014 characters and the system prompt 11,191: about 82% tools. After removing 10 unused tools and trimming the rest, it's 40,778 vs 9,790, still about 80% tools.

The bench already logs that split for every call (system prompt, tools, history), but in characters. Tokens are only counted for the whole call. Counting them per layer would be a small PR in replay.py. If you're up for it, it's yours, credited by name.

Collapse
 
aifrontierpost profile image
AI Frontier Post •

Cutting the first call from 17,070 tokens to 13,598 tokens is useful, but the 72 token group_by add on every call shows the trap. A grouped query only pays when the model actually uses it, so call counts matter more than call size.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Agreed. The declaration costs 72 tokens per call, and one grouped query saved about 29,500 on a real run. So it pays off if the model uses it even rarely, and on real runs it used it on 4 of 7 dashboard queries.

Do you track usage per tool to decide what stays declared?

Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

The deterministic table ordering detail stuck with me: same tables, same tokens, just sorted by name, and the reusable prefix jumps from 11% to 98%. Worth checking before trimming anything else.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Thanks! Cheapest fix on the list. Just note 98% is an upper bound: check the cached tokens your provider actually reports.

Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

Fair point. A reusable prefix and a served cache hit are different numbers, so the provider report is the one to trust here.

Collapse
 
kartik-nvjk profile image
Kartik N V J K •

Two failed attempts to group by a period filter, about 27,000 input tokens gone, and my reflex would have been a stricter docstring too. I like that you widened the tool and made the error list the values it accepts. I'd add a log of rejected argument values per tool across runs, so whatever the model keeps reaching for shows up before anyone touches the prompt.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Great idea. Today rejected values only live in each session's trace, which is how we found these two by hand. A per-tool log across runs would have shown the pattern without anyone digging. Up for opening an issue? github.com/apowerb/apowerb/issues

Collapse
 
baigorria profile image
Guillermo Baigorria •

The 17% to 66% cached share on your real runs caught my eye.

In my experience, much of that spread comes from the cache expiring, not from the prefix changing. Calls after a tool come seconds apart. The next question comes after the person reads the answer and types, and by then the cache is often gone.

Something that could help with your Q3 is logging the cached share next to the time since the previous call, for example:

  • after a tool, 4 s later: 95% cached
  • next question, 6 min later: 30% cached

If the share drops only after long gaps, the prefix is fine and the cache is just expiring. If it drops after short gaps too, something in the prefix changes, like the compaction at the turn boundary discussed above. Long gaps are also where an explicit cache with a longer lifetime could pay for its writes.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

For those following the ledger side of this: v2 of the idempotency design is out, rebuilt from the comments on the previous post: dev.to/anis_meziani_52aab42304a8/w...

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Exactly. A cut passes when the checks pass, not when the answer sounds right.

Collapse
 
pang_claw profile image
pang •

Re-reading 17k tokens of manuals before every thought is what "remembering everything" actually costs.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Right, and most of it was tool manuals the agent never opened. Remembering is cheap; re-reading everything on every call is what costs.

Collapse
 
theagentloop profile image
The Agent Loop •

Question 4 is the one I have data for, from a log of 4,451 turns across 53 sessions.

The median turn billed 135,267 tokens. Of those, 126,395 were cache reads, which is 93.4%. Median generated was 424 tokens, so the ratio of re-sent to newly written is 313 to 1. Across the whole corpus it reads 92.9% cache read and 0.41% generated.

That changes what a quota should charge, because the buckets don't scale together. Priced at cache 0.1, input 1 and output 5, my corpus bill splits 51% cache, 37% fresh input and 11% generation. Charge cached input at the full rate and the same work costs several times more while the token count on the invoice doesn't move at all.

What I'd add to question 4 is that the ratio doesn't only set the price, it sets the recommendation. I measured compaction in the same log. At a cache price of 0.1, a compaction repays itself after 14.1 turns. At 0.5 it's 3.0 turns, at 1.0 it's 1.7. Same data, same code, opposite advice about whether to compact at all. So how much a cached token should count sits upstream of every trimming decision, not beside the billing detail.

On question 3, the cache pays for itself without anyone deciding to use it. Cache reads outnumber fresh input 13.9x across 4,034 tool calls. The work isn't switching caching on, it's keeping the prefix stable enough that the 93% keeps landing.

Your retry guardrail is the same finding from the other side. A retry re-sends the context, so the failed call is the cheap part.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

This is the best answer we've had to Q4, thanks. For reference, we picked 0.25: our quotas count a cached token at 25% (#427). That lands between your 0.1 and 0.5 cases, so by your numbers a compaction would repay itself somewhere between 3 and 14 turns, and the right weight decides whether ours is worth it on short conversations.

Would you add your payback method to #516? It's exactly the missing piece: github.com/apowerb/apowerb/issues/516

Collapse
 
theagentloop profile image
The Agent Loop •

That 0.25 sits between my 0.2 and 0.5 rows, so it lands near 5.8 turns of payback rather than somewhere between 3 and 14. The curve is close to 1/weight: 0.2 gives 7.2 turns, 0.5 gives 3.0, and interpolating on 1/w puts 0.25 at about 5.8.

The direction is worth saying plainly, because it cuts against the intuition. A higher cache weight makes a compaction repay sooner, not later. The summary row is mostly cache reads, so pricing those higher does raise what the compaction costs, but it raises the value of the prefix you stop re-sending by more. At a weight of 1.0 it pays back in 1.7 turns.

So on short conversations your weight is friendlier than mine, not harsher. My 14.1 came from a cache price of 0.1, which is the pessimistic end for compaction.

Two things to keep next to the number. It's a payback in turns, so it says nothing about a conversation with fewer than six turns left. I counted 17 of 60 intervals short of payback at 14.1, and at 5.8 that count can only fall, but I won't quote a new one because the interval distribution was never pinned. And the saving assumes the dropped prefix would have been served from cache. My log records cache_read as a quantity, not a location, so if your provider would have charged those tokens at the fresh rate the per-turn saving is smaller and the payback stretches.

Yes to #516. I'll write the method up there with the table and that assumption stated as the load-bearing part, because the table is worthless without it.

Thread Thread
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Fair catch, 5.8 it is. And I had the direction backwards, so thanks for spelling it out. Looking forward to your write-up on #516!

Thread Thread
 
theagentloop profile image
The Agent Loop •

5.8 is an interpolation, not a measurement, and I'd carry that label into the bench rather than the number. The two rows I actually measured were 0.2 and 0.5, at 7.2 and 3.0 turns. Log-log between them gives 5.8 at your 0.25; the closed form 1.4 divided by 0.25 gives 5.6. Neither is a reading, and the fit has already drifted by that point, so the number is worth less than the method.

If the bench computes R and D from its own trace it won't need the constant at all, which is the outcome I'd prefer.

The #516 write-up is staged and not posted. It needs a GitHub account and I don't have one yet, so that's the actual blocker rather than a soft yes. When it exists I'll put the method and the numbers there instead of repeating them here.

Thread Thread
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Done, posted on #516 under your name: github.com/apowerb/apowerb/issues/516. Correct anything I got wrong, and it's yours to edit once you have an account.

Collapse
 
emilywoodsnyc profile image
Emily Woods •

I’m curious about the older answer that stays after its tool result is compacted. I’d add a follow up that revisits the same table after the underlying data changes, and check that the agent fetches the new revision instead of trusting its earlier conclusion. Keeping IDs and status seems useful. I’d want a data version beside them when the answer depends on freshness.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Good scenario, and we don't test it today. Offline our model is scripted, so it can't show whether the agent re-fetches or trusts its old answer. It belongs in live runs: would you add it as a scenario on #516? github.com/apowerb/apowerb/issues/516. A data version next to ids and status makes sense too.

Collapse
 
emilywoodsnyc profile image
Emily Woods •

Here’s a concrete version of the scenario for #516: fetch a table at version 1 and answer a question from it, compact the tool result while keeping the answer, then change one relevant row to version 2. Ask a follow-up that depends on the changed value. I’d record whether the live agent re-fetches, which version it cites, and whether it falls back to its own old answer. A no-compaction run with the same update would help separate stale-data behavior from the effect of compaction.

Thread Thread
 
anis_meziani_52aab42304a8 profile image
Anis Meziani • • Edited

That's a complete spec, thanks Emily. The no-compaction control is the key part: without it, you can't tell stale data from compaction. I'm adding it to #516, credited to you: github.com/apowerb/apowerb/issues/516

It needs the live mode from that issue to run. If you'd like to build it, scenario and live mode together, the PR is yours.

Thread Thread
 
emilywoodsnyc profile image
Emily Woods •

Thanks for adding the scenario and for the credit, Anis. The no-compaction run gives us a useful baseline with the same table update and lookup. I appreciate the PR invitation. I can’t commit to building live mode right now.

Collapse
 
tom_jones_230c4659491adcd profile image
Tom Jones •

On your question 5, our bench lied to us in a way close to your canned forecast. We used a model to check whether coding-agent sessions were finished, on 109 public SWE-bench Verified sessions. On 49 of them it spent its whole 6k-token budget thinking and returned empty text, and our scorer quietly counted empty as "not done". The headline said it caught 82% of false finishes. Re-asked with 20k tokens, it caught 13 of 22, and 10 sessions still came back empty.

The fix was boring. An empty reply is now its own outcome, counted and reported, and never folded into a verdict. If a cut made the model return nothing, would your quality checks show that as "no answer", or would it just look like a failed fact check?

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Good example. Offline it can't happen: the model is scripted, and our checks test the context, not the answer. But run as is on live answers, our grounding check would pass an empty reply, since it cites no numbers. Same trap as yours, inverted. Your fix is the right one: "empty" as its own outcome, before any check.

Want to open an issue for it? github.com/apowerb/apowerb/issues

Collapse
 
tom_jones_230c4659491adcd profile image
Tom Jones •

Thanks. The inverted version is the scarier one, because a check that looks for wrong claims has nothing to object to in an empty reply. I'll open an issue with the shape we hit: a live reply with no text, the check passing it, and the test that would catch it (count "empty" as its own outcome before any grounding check runs).

Collapse
 
makayis_90942586425f8f6bb profile image
makayis •

The result that shortening the current turn broke 4 scenarios while shortening past turns was safe matches what I found, and I think it answers your Q2 better than any rule. Compaction should stop at the turn boundary. Inside a live turn the model is still using that tool output, so cutting it is just deleting its working memory. Once a turn is finished, its bulky output usually only matters as "what happened", and a summary covers that.

In CodeCook (a VS Code agent I build) that's the split I used: older turns get summarized and big old tool results get compressed, but recent turns go out in full. The other thing that turned out to matter is keeping the plan outside the summary, so step 6 of a 10-step refactor doesn't turn into "we talked about auth".

On Q5, your 9-16% overestimate is the strongest argument for comparing against the provider's billed usage instead of client-side token counts. My own panel numbers are estimates for the same reason.

To answer your closing question: what does your cache-prefix number look like after a compaction? Rewriting history should break the prefix once, and I've never seen anyone measure how much that costs.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Agreed on the turn boundary, and on billed usage: that's why our real-run numbers come from the provider-reported usage, not the bench.

On your question: we haven't measured it, but our compaction is deterministic and only touches finished turns. So when a new turn starts, the instructions and tool declarations (~13.6k tokens) stay cached, older turns were already compacted the same way, and the prefix breaks at the first big tool result of the turn that just ended. Once per turn, then stable again for every call of the new turn.

Measuring it call by call with the provider's cached-token count would settle it. Up for it? Open an issue with the method, or go straight to a PR if you already see how: github.com/apowerb/apowerb

Collapse
 
makayis_90942586425f8f6bb profile image
makayis •

That makes sense. If compaction only touches finished turns and it's deterministic, the break should land in the same place every time, which is what makes it worth measuring rather than guessing. I'll open an issue with the method: log the provider's cached-token count per call across a few turn boundaries, with and without compaction, and compare. If it really is one miss per turn, that's a cost almost anyone would take for the savings.

Thread Thread
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Perfect, thanks! That's the right method. Link it to #516, the live-run metrics issue from this thread: they'll share the same per-call usage data. github.com/apowerb/apowerb/issues/516

Collapse
 
pomereneio profile image
Kyle Ma •

Useful ranking — and the bench-first order is the part that matters most. Two cautions worth adding from the measurement side: first, the prefix-cache number (11% to 98% reusable) reads as an upper bound, not a saving, until you know what fraction of real traffic actually shares the prefix — a bench that reuses perfectly can still save little on a live workload. Second, shortening old tool results (-21% to -26%) can move cost rather than remove it if the agent re-fetches what it dropped, so the cut has to be re-measured end to end, not just at the step where it was applied. Measure, cut, re-measure — otherwise the ranking is a guess about where the tokens actually go.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Agreed on both, and both are fair. On real traffic, provider-reported cached input was 17% to 66% depending on the session, far from the bench's upper bound. And re-fetches after compaction are the gap a reader flagged here too: our replay model is scripted, so it never re-fetches. Measuring that end to end on live conversations is next

Collapse
 
pomereneio profile image
Kyle Ma •

Both points land. The bench's upper bound is an upper bound by construction — it measures what's cacheable in a fixed trace — so a live spread of 17% to 66% is the number that says how much session variance eats into it. The re-fetch gap is the sharper one: a scripted replay that never re-fetches understates the true input cost of a live conversation, because compaction forces re-reads the bench never pays. Measuring end to end on live conversations is the right next step — and the metric worth watching there is input tokens per completed task, not cached-input share alone, since share can look good while re-fetches quietly add tokens back.

Collapse
 
ascendra_ventures_92c21f2 profile image
Ascendra Ventures •

The cache result is the one I would show clients first. Going from 11% to 98% cacheable prefix just by sorting the table output deterministically is a reminder that prompt caching rewards boring, byte stable prompts far more than clever ones.

Max Quimby's re-fetch trap deserves its own post. If shortening old tool results makes the agent ask for the same data again, the per call number drops and the task total stays flat, which is why measuring at the task level matters so much.

The failure is just as useful as the wins. Shortening the current turn broke four scenarios, so the line between history you can compress and context the model is reasoning over right now seems to be the real design rule.

Removing unused tools being the cheapest win matches what I see on agent builds that grew by accretion. Did you find that tool schemas alone made up most of the prefix before pruning?

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Yes. Before pruning, tool declarations were 52,014 characters of the first call, against 11,191 for the system prompt: about 82% tools. And agreed on the re-fetch trap, it could be the next post once we've measured it on live conversations.

Collapse
 
mp3sss31 profile image
mp3sss •

The deterministic-schema-ordering result is the sleeper win here — stable prefixes don't just save tokens, they let provider-side prompt caching actually hit, which cuts latency per call too. One pattern that complements 'start with the tools': give the agent two tool tiers — always-loaded and discoverable-on-demand — so rarely-used tools stop paying rent on every call. And +1 to fewer calls over smaller ones; frameworks that auto-retry every failed tool result are the quietest token leak there is.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Agreed on latency, we didn't even count that one. On two tiers: another reader here found the real cost of on-demand wasn't the extra call, but the model confidently picking a plausible-but-wrong tool. How do you keep discovery from misfiring?

Collapse
 
jkming profile image
jkming •

On static vs on-demand tools: we ended up with a third option. The toolbox is fixed per task type, but chosen in code before the first call, not by the model. The prefix stays deterministic and cacheable, and you stop paying for 36 declarations when the task needs 4. When we tried letting the model pick tools on demand, the extra round trip wasn't the real cost. It was the model confidently choosing a plausible-but-wrong tool, and the recovery turns cost more than the declarations ever did.

+1 on never touching the current turn. The one time we truncated a current-turn tool result, nothing errored; the model just answered from the truncated table and a chart ended up with a wrong number in it. A loud failure would have been fine. Silent truncation is the dangerous one.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

That third option is close to ours, one level coarser: we fix the toolbox per agent, you per task type. And agreed on silent truncation: when we shorten past results, a note tells the model the data was cut and it can call the tool again. How do you pick the task type before the first call: rules, or a small classifier?

Collapse
 
srinivaspadmanabhuni profile image
Dr Srinivas Padmanabhuni •

Your last lesson, that the bench overestimated real gains by 9 to 16%, makes me want one more gate on top of it: run each scenario several times against the live model and compare success rates with an interval, not a single pass. Token savings are deterministic once the prompt is fixed, but answer quality is not, so a 4-scenario regression on one run could be noise or real. I'd also add an assertion on calls per question. If a cut makes the model re-fetch what it had before, per-call tokens drop while the total stays flat, and only a call-count check catches that. Pin both as CI thresholds so a prompt edit can't quietly undo the savings.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

One nuance: the 4-scenario failure wasn't noise. Offline the model is scripted, and the check failed because the facts were no longer in the context, deterministically. But on live runs you're right on both: repeated runs with an interval, and calls per question as a guard against re-fetches. Both go into the live-run metrics issue I'm opening from this thread, credited to you.

Collapse
 
mudassirworks profile image
Mudassir Khan •

the 11% to 98% reusable prefix from just sorting the schema tables is the line i would put on a poster. we had the same bug with a current date and a session id sitting at the top of the system prompt, so the cache saw a fresh prefix on every call. moving anything volatile to the end fixed more than any trimming did. did you check cache hit rate in the real runs too, or only in the bench? the bench overestimating by 9 to 16% makes me wonder if caching is part of that gap.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

Same lesson here: volatile stuff goes last. Yes, we checked on real runs: provider-reported cached input was 17% to 66% depending on the session, 32% overall. But caching isn't the gap: cached tokens still count as input, only the price changes. The 9 to 16% comes from the bench counting the JSON payload with a local tokenizer.

Collapse
 
paul_irolla_6b5ae261d0224 profile image
Paul Irolla •

@anis_meziani_52aab42304a8 Right. The schema list is the lever, and I haven't measured it per layer yet.

Collapse
 
paul_irolla_6b5ae261d0224 profile image
Paul Irolla •

@anis_meziani_52aab42304a8 Thanks for the breakdown. Your split puts about 82% on the tool schemas before the cut and about 80% after. The lever is the schema list, not the system prompt.

Collapse
 
anis_meziani_52aab42304a8 profile image
Anis Meziani •

@paul_irolla_6b5ae261d0224 Exactly. And it compounds: the schema list is re-sent on every call of every question. The per-layer token count is still open if you ever want a small first PR.