Tokens are one of the easiest AI costs to underestimate.
An agent may appear to generate only a short response, but behind that response could be thousands of tokens from system instructions, conversation history, retrieved documents, tool outputs, and previous reasoning steps.
The result is an agent that becomes progressively more expensive as conversations become longer.
Why AI agents consume so many tokens
Traditional chatbot interactions are relatively straightforward.
An AI agent can be very different.
A single task might include:
System instructions
User input
Previous conversation
Retrieved documents
Tool responses
Agent state
Structured outputs
Previous intermediate results
If all of this information is repeatedly sent to the model, token usage can grow rapidly.
Don't send the entire context every time
One common mistake is treating the entire conversation history as necessary context.
It usually isn't.
Instead, agents can use:
Conversation summaries
Relevant memory
Task-specific context
Metadata
Retrieval
Structured state
For example, instead of sending 30 previous messages to an agent, the system could maintain a concise summary containing the information actually required for the next decision.
This reduces context size while maintaining continuity.
Use the right model for the right task
Not every agent decision requires the most capable model.
A workflow might use:
Smaller model → classification
Smaller model → extraction
Smaller model → routing
Larger model → complex reasoning
This approach is often much more efficient than sending every request to the most expensive model.
Reduce unnecessary agent loops
Agents sometimes repeat the same reasoning process:
Think → call tool → think → call tool → think → call tool → answer.
If the workflow requires five iterations for a task that could have been completed in two, you're paying for unnecessary inference.
Good agent design should establish:
Maximum iterations
Clear stopping conditions
Tool-use rules
Failure handling
Escalation conditions
Optimize prompts
Long prompts aren't automatically better prompts.
A useful system prompt should be:
Clear
Specific
Structured
Relevant
Free from unnecessary repetition
Instead of explaining the same rule multiple times, encode the rule once and make the expected output explicit.
Cache what doesn't change
If an agent repeatedly processes the same information, caching can significantly reduce unnecessary processing.
Examples include:
Frequently requested documentation
Product information
Static policies
Common API responses
Repeated embeddings
Measure tokens per successful task
Don't just monitor total tokens.
Track:
Tokens consumed ÷ successful tasks
This gives you a much better picture of whether your optimization is actually working.
Comments
Log in or sign up to join the conversation.