{
  "video": {
    "id": "uiP88SpCi1Q",
    "title": "Your Agent Is Wasting Tokens and You Don't Know It - Erik Hanchett, AWS",
    "duration": 355,
    "upload_date": null,
    "channel": "AI Engineer",
    "source": "AI Engineer",
    "event_format": "Online"
  },
  "analysis": {
    "video_id": "uiP88SpCi1Q",
    "title": "Your Agent Is Wasting Tokens and You Don't Know It - Erik Hanchett, AWS",
    "one_liner": "Erik Hanchett (AWS developer advocate) gives a five-minute rundown of five concrete ways to cut agent token costs: cache the system prompt, route by task difficulty, offload large tool results, cap tool loops, and trim conversation history.",
    "summary": "A lightning talk enumerating five token-saving techniques for agents, demonstrated with pseudo-code in AWS's Strands Agents (though the speaker notes the ideas work across providers). The argument is that most token waste comes from resending the same content — system prompts, tool results, and full conversation histories — on every loop of the agent, plus using an expensive frontier model for tasks that don't need one. He recommends running observability tooling before deployment to see how long each tool call takes and how many times it loops, then iterating on that data.",
    "key_points": [
      "Cache the system prompt: in Strands Agents, `cache_prompt=\"default\"` sends the full system prompt on the first call and a much reduced one on every subsequent call; tool prompts and messages can also be cached.",
      "Route by difficulty: use a cheap model such as Claude Haiku for simple tasks and Claude Sonnet for harder ones, selected with an if-statement — or have a very cheap model decide which model to use.",
      "Offload tool results: store a large tool result locally or in the cloud and pass a summarization instead, so the full result isn't re-added to context on every agent loop. He shows the manual version; Strands also offers APIs for it.",
      "Cap tool loops: he's repeatedly seen agents call a tool 10 or 20 times, or spin into an infinite loop, so always set a max-iterations limit.",
      "Run observability tools before deploying to inspect every tool call — how long each runs and how many times it loops — to gauge tool-call efficiency.",
      "Trim history: multi-turn conversations resend the whole history each call, eating hundreds if not thousands of tokens. Strands' sliding window conversation manager keeps only the last 10 messages (configurable).",
      "The stated trade-off of the sliding window is losing the early message history; the fix is to summarize what falls out of the window and put that summary into the context."
    ],
    "takeaways": [
      "Turn on prompt caching for system prompts, and where possible tool prompts and messages, rather than resending them every call.",
      "Stop defaulting to the most expensive model for every task — build difficulty-based routing across a cheap and a stronger model into the agent.",
      "Keep large tool results out of the agent loop by storing them externally and feeding back a summary.",
      "Set a max-iterations cap on tool loops so a runaway or infinite loop can't burn tokens.",
      "Apply a sliding window to multi-turn conversation history, paired with a summary of the dropped messages so early context isn't simply lost."
    ],
    "topics": [
      "agents",
      "token-costs",
      "prompt-caching",
      "model-routing",
      "context-management",
      "observability",
      "tool-calling"
    ],
    "tools": [
      "AWS",
      "Strands Agents",
      "Claude Haiku",
      "Claude Sonnet",
      "sliding window conversation manager",
      "programwitheric.com",
      "LinkedIn"
    ],
    "quotes": [
      {
        "text": "I highly recommend don't use the most expensive model for everything you're doing. You want to use multiple different models based on the use case.",
        "at": "01:38",
        "url": "https://www.youtube.com/watch?v=uiP88SpCi1Q&t=98s"
      },
      {
        "text": "If you don't cap that tool call, then it might run 10, 20 times. It might get into an infinite loop, which would be very bad for your token usage.",
        "at": "02:59",
        "url": "https://www.youtube.com/watch?v=uiP88SpCi1Q&t=179s"
      },
      {
        "text": "That whole conversation history will be sent back to the large language model. And this can eat through hundreds, if not thousands, of tokens.",
        "at": "03:55",
        "url": "https://www.youtube.com/watch?v=uiP88SpCi1Q&t=235s"
      },
      {
        "text": "The downfall of this, or the trade-off of this, I should say, is that you will lose the message history from the beginning.",
        "at": "04:25",
        "url": "https://www.youtube.com/watch?v=uiP88SpCi1Q&t=265s"
      }
    ],
    "words": 1144
  },
  "summary_url": "/#uiP88SpCi1Q",
  "transcript": {
    "html": "/transcripts/uiP88SpCi1Q.html",
    "txt": "/transcripts/uiP88SpCi1Q.txt",
    "vtt": "/transcripts/uiP88SpCi1Q.vtt"
  }
}