A few thoughts on tokenomics for AI agents
What I’ve been learning about tool calling, caching, model routing and focused subagents, and the trade-offs behind reducing agent costs.
I’ve been thinking about tokenomics: being more intentional about where our tokens go and what we’re paying for when building AI agents.
A single request can involve several model calls, tool results, retries and maybe a few subagents. It all adds up, and there are quite a few places where we could avoid unnecessary work.
I’ve been learning about different ways to approach this and thought I’d collect a few here, along with some of the trade-offs that come with them.
Some help us use fewer tokens. Others help us spend less on the tokens we still need.
1. Programmatic tool calling
One approach I’ve been reading about is letting the agent write a script that coordinates several tool calls, handles intermediate results and returns just what the model needs.
Imagine asking an agent to find your top five customers by spending across three sources. A script could fetch the records, combine them, calculate the totals and return those five customers. The model doesn’t necessarily need to read every transaction to answer the question.
This can reduce the back-and-forth where the model calls one tool, reads the result, then calls another. It also keeps unnecessary intermediate data out of its context.
Anthropic calls this programmatic tool calling. What I find interesting is deciding which parts of a workflow need another model decision and which can be handled directly in code.
2. Semantic caching
Semantic caching lets us reuse a previous answer when it fits a new request, even if the wording is different.
I’ve been exploring Redis for the cache and Jev for checking whether a candidate answer actually covers the new question. I wrote about my experiment here.
The tricky part is false positives. Two questions can sound similar and still need different answers.
For example, “Can I transfer my ticket?” and “How do I transfer my ticket, and what’s the deadline?” are closely related. But a cached answer that simply says “Yes, tickets are transferable” won’t answer the second question.
So finding a similar question is only part of the job. We also need to decide whether its answer can be reused.
That verification step has its own cost too. When measuring the savings, we need to account for the cache lookup, verification and any fresh generation needed when an answer can’t be reused.
3. Model routing
Different tasks can use different models.
Things like classification or straightforward extraction might work perfectly well with a smaller, cheaper model. More demanding tasks might benefit from a more capable one.
The useful question is whether the cheaper model meets the quality requirements for that particular task.
For example, extracting an order ID from a message is a different job from investigating why an order failed across several systems. There’s room to make different choices within the same application.
A cheaper model that needs several retries might not save much, though. It’s worth testing on your actual tasks and including retries and escalation in the cost.
4. Prompt caching
Agents often send the same instructions, tool definitions and background information across several requests.
Prompt caching lets the provider reuse some of the work involved in processing that repeated input. The model still generates a fresh response.
That’s a useful distinction from semantic caching: one reuses prompt processing; the other reuses an answer.
Your provider might already enable prompt caching, although the details depend on the model and API. Keep reusable content stable near the beginning of the prompt, configure cache boundaries where needed, and check that you’re actually getting cache hits.
This can reduce the cost of repeated input without reducing the amount of context the model receives.
5. Context isolation with subagents
A subagent can handle a focused task with the information it needs, then return a concise result to the main agent.
For example, it could investigate a particular question without passing every search result and intermediate step back into the main conversation. Anthropic describes this pattern in its context engineering guide.
This can help keep the main agent’s context manageable, especially when a task involves a lot of investigation.
But extra agents also do extra work. If the task boundaries aren’t clear, they can duplicate effort or spend tokens coordinating with each other.
So a smaller main context doesn’t automatically mean a smaller total bill. We still need to measure usage across the whole system.
I’m still figuring out which combinations make sense for different workloads. The useful measure for me is what it costs to complete the whole task correctly, including the checks, retries and fallbacks along the way.
What have you guys tried to reduce token usage or cost in your agents? Keen to know what’s worked! :)
Do you have any thoughts, corrections or questions? I'd love to hear from you.
Get the next note
New notes when I publish. No schedule, no filler.