AI agents powered by models like Claude are revolutionizing automation. But as these agents loop through tasks—reasoning, acting, and observing—they can quietly burn through tokens, driving up costs. Here are seven common mistakes to avoid.
1. Neglecting a Clear Exit Strategy
The most expensive
mistake is an agent that never stops. This happens when an agent enters an infinite loop, repeatedly calling a tool without making progress. The cause is often a lack of clear, deterministic termination conditions. An agent might get stuck trying the same failing action, misinterpreting tool output, or having a goal that's too ambiguous to ever be considered 'done'. To prevent this, developers must implement hard limits, such as a maximum number of iterations or a timeout. More sophisticated solutions involve creating an explicit 'stop' signal or a dedicated tool the agent must call to signify task completion, ensuring every loop has a guaranteed exit.
2. Sending the Entire History Every Time
Agent loops work by feeding the context of the entire conversation back to the model with every turn. As a conversation grows, this becomes incredibly inefficient. A long history not only consumes a massive number of input tokens but can also degrade the model's performance by burying relevant information in a sea of noise. The solution is aggressive state management. Instead of sending the full, raw history, use a summarization technique. This can be as simple as a sliding window that only keeps the last few turns or a more advanced method where a cheaper, faster model condenses older parts of the conversation. For recurring tasks, starting fresh conversations is often more efficient than continuing a long-running one.
3. Using Verbose or Unstructured Tools
An agent is only as good as its tools. When a tool returns a verbose, unstructured wall of text—like a raw log file or a full HTML page—it forces Claude to spend tokens and processing power just to find the relevant data. This is a hidden cost that adds up over many cycles. The best practice is to design 'contracts' for your tools. They should be built to return minimal, structured data (like JSON) containing only the necessary information. For example, instead of returning an entire 10,000-line test log, a wrapper can be used to filter it down to just the specific error message and stack trace. This makes the tool's output immediately useful and dramatically reduces the token load on the model.
4. Writing Vague System Prompts and Instructions
The system prompt is the agent's constitution, sent with every single call. A long, rambling prompt is a constant token drain. If instructions are unclear or tool descriptions are ambiguous, the model is more likely to make mistakes, requiring more loops—and more tokens—to correct its course. A high-quality prompt is concise and explicit. It clearly defines the agent's role, constraints, and success criteria. Tool descriptions should be written like API documentation for someone who will never ask a follow-up question, eliminating overlap and guesswork. A tight, focused system prompt not only saves tokens on every turn but also improves the agent's reliability.
5. Using the Strongest Model for Every Task
Not all tasks require a frontier model like Claude's most powerful variant, Opus. Many subtasks within an agentic loop, such as simple data extraction, classification, or formatting, can be handled perfectly well by cheaper, faster models like Sonnet or Haiku. Defaulting to the most expensive model for every single step is a significant waste of resources. A more cost effective architecture uses a 'router' or 'orchestrator' agent. This primary agent assesses a task and delegates it to the most appropriate subagent or model. This 'right model for the right job' approach ensures you are only paying for maximum reasoning power when you genuinely need it.
6. Forgetting to Cache Repetitive Calls
Agents often need to access the same information multiple times within a task. For example, they might repeatedly call a tool with the identical input or require a static piece of context like a project s file structure. Re running these calls and re sending this data from scratch every time is redundant. This is where caching comes in. For tool calls, a simple caching layer can store the results of previous calls and return the stored result if the same input is seen again, saving both tokens and execution time. For static context, Anthropic s prompt caching feature can significantly reduce the cost of re sending system prompts or large documents, offering a substantial discount on the most stable parts of your context window.
7. Lacking a Persistent State Manager
Standard API calls are stateless, meaning the agent forgets everything once a session ends. Without a system for managing state, an agent can t learn from past interactions or reliably handle long running, multi step tasks. If a loop is interrupted, a stateless agent has to start over. Production grade agents require a state management system, whether through a framework like LangGraph or a custom implementation with a database. This infrastructure handles session persistence, allows agents to pause and resume, and ensures that multiple agents can coordinate by accessing a single 'shared truth' about the task s status.













