Skip to main content

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:

ViewWhat it does
DashboardShows 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.
AnalyticsShows the detailed numbers, in three tabs: MCP Gateway, Conversations, and Devices.
OptimizeThis 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:

DriverWhat it isWho measures it
Session contextThe 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 responsesThe data that MCP tools send back into the conversation.The gateway measures this.
ConversationsPrompts and replies. This includes the earlier messages, which are sent again with every new prompt.Claude reports this.
Never add the three cost drivers together

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:

SourceWhy it matters
MCP contextMCP 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 contextA 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 contextWillow 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 responsesA 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

  1. Enable Token Usage Analytics.
  2. Read the Dashboard to see which of the three drivers costs the most.
  3. Work through the Start here actions, or open Optimize for the full list.
  4. In the context inventory, reduce the MCP servers, toolkits, and skills that use the most tokens.
  5. Set usage policies if long conversations or expensive models are what costs you the most.
  6. Change the output format if tool responses use a large share of your tokens.

Pages in this section