WhoBuilt

Your Agent Is Wasting Tokens and You Don't Know It

Jun 28, 2026· 6 min· 1.9K views·Watch on YouTube

Speaker

Erik Hanchett, a senior developer advocate at AWS, explains five ways to reduce token costs while using and building agents at an AI Engineer talk.

Cache repeated prompts

Hanchett recommends caching the system prompt so later agent calls send less prompt text. He uses AWS Strands Agents as an example and says tool prompts and messages can also be cached.

Route tasks by difficulty

Use a more capable model for difficult tasks and a cheaper one for simpler tasks. Hanchett gives Claude Haiku and Claude Sonnet as examples, and suggests routing with an if statement or a low-cost model.

Reduce repeated tool output

Large tool results can be stored locally or in the cloud, then summarized before being used again. This avoids adding the full result to the agent context every time the tool or agent loop runs.

Limit and observe tool loops

Set a maximum number of tool iterations because an agent may repeat calls 10 or 20 times or enter an infinite loop. Observability tools can show tool usage, duration, and loop counts to help identify inefficient calls.

Trim conversation history

Long conversations can send the full history to the model on every call, using hundreds or thousands of tokens. Strands Agents offers a sliding window conversation manager; Hanchett describes keeping the last 10 messages and summarizing earlier history to preserve useful context.

Takeaways

  • Cache stable system prompts and other repeated prompt content.
  • Choose models based on task difficulty instead of using an expensive model for every task.
  • Store and summarize large tool results so they are not repeatedly sent into the agent context.
  • Set a maximum number of tool iterations and use observability to spot excessive calls.
  • Keep a bounded conversation window and summarize older messages when long-term context matters.

Mentioned in this talk

Search inside this talk

What was claimed 6

Related talks