Token Optimization and Analytics
Token Optimization and Analytics helps admins do two things: see how much their AI agents spend on tokens, and reduce that spend.
All of these features are on a single page, Monitor > Tokens, titled Token Optimization. The page has three views:
| View | What it does |
|---|---|
| Dashboard | Shows costs. It lists your estimated monthly spend, the savings you could make, the three cost drivers in order of cost, the changes that would save the most, and a summary of context health. |
| Analytics | Shows the detailed numbers, in three tabs: MCP Gateway, Conversations, and Devices. |
| Optimize | This is where you make changes. It has recommended actions with their estimated savings, usage policies, and the context inventory. |
Start on Dashboard to find out which parts of your setup cost the most. Then open Optimize to make changes.
How the pieces fit together
The gateway is the Willow MCP gateway. Every tool call your AI agents make passes through it, so Willow can count those tokens directly.
AI agents use tokens in several places. Willow groups these places into three cost drivers:
| Driver | What it is | Who measures it |
|---|---|---|
| Session context | The tool definitions and skills that load at the start of every session. | The gateway measures this for every AI agent that connects through Willow. |
| Tool responses | The data that MCP tools send back into the conversation. | The gateway measures this. |
| Conversations | Prompts and replies. This includes the earlier messages, which are sent again with every new prompt. | Claude reports this. |
The gateway measures session context and tool responses. Claude reports conversation spend separately. Some of the same tokens appear in both measurements.
If you add Session context + Tool responses + Conversations, you count some tokens twice and get a total that is too high. Compare the three drivers against each other to decide what to fix first. Do not add them up.
Four things decide how much session context each session loads:
| Source | Why it matters |
|---|---|
| MCP context | MCP servers publish a description and an input schema for each of their tools. A server with many tools adds a large amount of context, even if the agent never calls any of those tools. |
| Toolkit context | A toolkit gives agents a chosen group of tools instead of every tool on a server. A toolkit with fewer tools loads less session context. |
| Skill context | Willow loads your skills into every session. A large skill therefore adds its full token cost to every session, even sessions that never use it. |
| Tool responses | A tool can return a large amount of data into the conversation. A response mapping is a rule that keeps only the fields you need, which lowers the number of tokens the model receives. |
The dollar figures are estimates, not a bill
Willow calculates the dollar figures on these pages. They are not amounts that anyone has charged you, and they will not match your invoice.
To produce them, Willow counts your tokens and multiplies that count by the published price of one named AI model. The Dashboard tells you which model it used, for example priced at Claude Opus 4.7.
Use these figures to decide which problem to fix first. Do not use them for accounting or billing.
The normal workflow
- Enable Token Usage Analytics.
- Read the Dashboard to see which of the three drivers costs the most.
- Work through the Start here actions, or open Optimize for the full list.
- In the context inventory, reduce the MCP servers, toolkits, and skills that use the most tokens.
- Set usage policies if long conversations or expensive models are what costs you the most.
- Change the output format if tool responses use a large share of your tokens.
Pages in this section
- Enable Token Usage Analytics - turn on the beta feature in Settings.
- Review Token Usage - read the Dashboard, Analytics, and Optimize views.
- Usage Policies - limit how long conversations can get, set a monthly spending limit for expensive models, and deploy the Usage Hooks plugin.
- MCP Context - find MCP servers whose tool descriptions and input schemas use a lot of tokens.
- Toolkit Context - use toolkits to reduce session context.
- Skill Token Analysis - find skills that are too large, and move their detail into references.
- Tool Response Optimization - find high-token tool responses that have no response mapping.
- Output Format Optimization - set the tool output format from the Optimize view.