<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Anannya Roy Chowdhury</title>
    <description>The latest articles on DEV Community by Anannya Roy Chowdhury (@royanannya).</description>
    <link>https://dev.to/royanannya</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3813086%2F9b30135b-af43-4b2d-80ba-cc780071faa5.png</url>
      <title>DEV Community: Anannya Roy Chowdhury</title>
      <link>https://dev.to/royanannya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/royanannya"/>
    <language>en</language>
    <item>
      <title>Have you wasted cost on too many tokens and too many interactions? I did too.

The fix wasn't a better model. It was a better architecture. Moving state outside the LLM &amp; simplifying agent interactions cut costs by 82%.
Read more here on how I did it.</title>
      <dc:creator>Anannya Roy Chowdhury</dc:creator>
      <pubDate>Fri, 17 Jul 2026 08:00:43 +0000</pubDate>
      <link>https://dev.to/royanannya/have-you-wasted-cost-on-too-many-tokens-and-too-many-interactions-i-did-too-the-fix-wasnt-a-n6g</link>
      <guid>https://dev.to/royanannya/have-you-wasted-cost-on-too-many-tokens-and-too-many-interactions-i-did-too-the-fix-wasnt-a-n6g</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/royanannya/my-multi-agent-ai-cost-1847-in-one-weekend-heres-the-fix-that-cut-it-82-3mi4" class="crayons-story__hidden-navigation-link"&gt;My Multi-Agent AI Cost $1,847 in One Weekend — Here's the Fix That Cut It 82%&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/royanannya" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3813086%2F9b30135b-af43-4b2d-80ba-cc780071faa5.png" alt="royanannya profile" class="crayons-avatar__image" width="800" height="800"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/royanannya" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Anannya Roy Chowdhury
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Anannya Roy Chowdhury
                
              
              &lt;div id="story-author-preview-content-4017093" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/royanannya" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3813086%2F9b30135b-af43-4b2d-80ba-cc780071faa5.png" class="crayons-avatar__image" alt="" width="800" height="800"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Anannya Roy Chowdhury&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/royanannya/my-multi-agent-ai-cost-1847-in-one-weekend-heres-the-fix-that-cut-it-82-3mi4" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jul 16&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/royanannya/my-multi-agent-ai-cost-1847-in-one-weekend-heres-the-fix-that-cut-it-82-3mi4" id="article-link-4017093"&gt;
          My Multi-Agent AI Cost $1,847 in One Weekend — Here's the Fix That Cut It 82%
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/agents"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;agents&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/programming"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;programming&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/architecture"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;architecture&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/royanannya/my-multi-agent-ai-cost-1847-in-one-weekend-heres-the-fix-that-cut-it-82-3mi4" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/raised-hands-74b2099fd66a39f2d7eed9305ee0f4553df0eb7b4f11b01b6b1b499973048fe5.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;27&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/royanannya/my-multi-agent-ai-cost-1847-in-one-weekend-heres-the-fix-that-cut-it-82-3mi4#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              12&lt;span class="hidden s:inline"&gt;&amp;nbsp;comments&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            8 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>My Multi-Agent AI Cost $1,847 in One Weekend — Here's the Fix That Cut It 82%</title>
      <dc:creator>Anannya Roy Chowdhury</dc:creator>
      <pubDate>Thu, 16 Jul 2026 11:31:13 +0000</pubDate>
      <link>https://dev.to/royanannya/my-multi-agent-ai-cost-1847-in-one-weekend-heres-the-fix-that-cut-it-82-3mi4</link>
      <guid>https://dev.to/royanannya/my-multi-agent-ai-cost-1847-in-one-weekend-heres-the-fix-that-cut-it-82-3mi4</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 1 of "Multi-Agent Systems in Production: What They Don't Tell You" — a four-part series following the saga of Horcrux Hunt, a multi-agent Harry Potter game that taught me everything about production AI the expensive way.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Weekend My Game Cost More Than My Rent
&lt;/h2&gt;

&lt;p&gt;I built Horcrux Hunt, an interactive Harry Potter-themed game where two AI agents battle each other live in front of an audience. Harry (the protagonist, powered by Claude on Amazon Bedrock via Strands SDK) hunts Horcruxes hidden across 15 locations. Voldemort (the adversary) relocates them, plants decoys, and corrupts Harry's beliefs.&lt;/p&gt;

&lt;p&gt;Think of it as adversarial hide-and-seek between two LLMs, with a live audience voting and watching Harry's search unfold in real-time on a Streamlit dashboard.&lt;/p&gt;

&lt;p&gt;It was supposed to be a fun weekend demo. The audience loved it. The CloudWatch metrics did not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The bill: $1,847 for one weekend.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;More than my rent.&lt;/p&gt;

&lt;p&gt;And the performance was terrible:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;12-second latency&lt;/strong&gt; per turn (audience literally waiting)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;23% win rate&lt;/strong&gt; for Harry (he almost never won)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;18% timeout rate&lt;/strong&gt; (Lambda functions dying mid-thought)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;67% of costs&lt;/strong&gt; from Bedrock LLM calls alone&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The audience feedback said things like "game is slow" and "Harry seldom wins." They didn't know it was also bankrupting me.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Multi-Agent Systems Cost More Than You Think
&lt;/h2&gt;

&lt;p&gt;We build multi-agents systems. We keep adding agents for every task. But we never ask - &lt;strong&gt;"How many agents are too many"&lt;/strong&gt; ? Here's the formula nobody shows you when they pitch multi-agent architectures:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Cost = tokens × agents × turns × retries × context_replay
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each term multiplies the others. It's not additive, it's multiplicative. Let me break down why, using Horcrux Hunt as the anatomy lesson.&lt;/p&gt;

&lt;h3&gt;
  
  
  Context Windows Compound Exponentially
&lt;/h3&gt;

&lt;p&gt;Every turn of Horcrux Hunt, the game feeds Harry the entire conversation history like every search, every signal, every ally ability used. By turn 50, that's a LOT:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs2ibk58wamgsfdd8jtv3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs2ibk58wamgsfdd8jtv3.png" alt=" " width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every single turn, the LLM re-reads the &lt;strong&gt;entire&lt;/strong&gt; conversation history. It's like Harry reading his complete mission journal from page one every time he makes a decision. By turn 50, you're paying 7.5× what turn 1 cost and that's just one agent.&lt;/p&gt;

&lt;p&gt;With two agents (Harry AND Voldemort), you have 2× the token curve. Each agent maintaining its own inflating context.&lt;/p&gt;

&lt;h3&gt;
  
  
  Output Tokens Are the Hidden Killer
&lt;/h3&gt;

&lt;p&gt;Most people focus on input tokens. But output tokens cost &lt;strong&gt;5× more&lt;/strong&gt; than input tokens on most models (Claude 3 Sonnet: $0.003/1K input vs $0.015/1K output). And they're sequential costing 12ms per token, and can't be parallelized.&lt;/p&gt;

&lt;p&gt;Harry's responses averaged 150-200 output tokens per turn. Voldemort's averaged 100-150. Across 50 turns × 2 agents, output tokens accounted for 39% of wall-clock time. The audience was waiting for &lt;em&gt;token generation&lt;/em&gt;, not thinking.&lt;/p&gt;

&lt;h3&gt;
  
  
  One Turn Is Actually 12 Operations
&lt;/h3&gt;

&lt;p&gt;What I imagined a turn looked like:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Harry thinks → 2. Harry acts → 3. Voldemort responds&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F67othqevjiuy7e927kcz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F67othqevjiuy7e927kcz.png" alt=" " width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What a turn actually required:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Load game state from DynamoDB&lt;/li&gt;
&lt;li&gt;Compute valid actions (which locations are on cooldown?)&lt;/li&gt;
&lt;li&gt;Build Harry's context (compress game history)&lt;/li&gt;
&lt;li&gt;Call Bedrock for Harry's decision&lt;/li&gt;
&lt;li&gt;Validate Harry's response (is the action format correct? Is it a legal move?)&lt;/li&gt;
&lt;li&gt;Execute Harry's action (update game board, resolve signals)&lt;/li&gt;
&lt;li&gt;Compute Voldemort's context&lt;/li&gt;
&lt;li&gt;Call Bedrock for Voldemort's decision (or use heuristic)&lt;/li&gt;
&lt;li&gt;Validate Voldemort's response&lt;/li&gt;
&lt;li&gt;Execute Voldemort's action (relocate Horcrux? Plant decoy?)&lt;/li&gt;
&lt;li&gt;Update shared game state (locations, signals, scores)&lt;/li&gt;
&lt;li&gt;Persist to DynamoDB + emit CloudWatch metrics&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;50 turns × 12 operations = &lt;strong&gt;600 operations per game&lt;/strong&gt;. The sequential nature is the real bottleneck. You can't parallelize Harry and Voldemort because Voldemort's action depends on what Harry just did.&lt;/p&gt;

&lt;h3&gt;
  
  
  Failing Slow, Failing Expensive
&lt;/h3&gt;

&lt;p&gt;Here's what I noticed when I analyzed my retry rate: &lt;strong&gt;15% of LLM responses failed validation.&lt;/strong&gt; Harry would produce an invalid action format, or try to search a location on cooldown, or attempt to use an ally ability he'd already spent.&lt;/p&gt;

&lt;p&gt;Each failure: 3 seconds of reasoning → rejected → full context replayed → try again. Each retry cost full token price.&lt;/p&gt;

&lt;p&gt;The system was discovering failures &lt;em&gt;after&lt;/em&gt; spending money. Failing slow (3 seconds into inference). Failing expensive (full token cost per failure). I'd later name the opposite of this pattern.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Cost Math That Scared Me
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbzminhwnpwf0ajok59z7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbzminhwnpwf0ajok59z7.png" alt=" " width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Per game:&lt;/strong&gt; ~$1.95 (naive approach)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;1,000 games/day:&lt;/strong&gt; $1,950/day&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monthly:&lt;/strong&gt; ~$49,000&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Annual:&lt;/strong&gt; ~$588,000&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a game. A two-agent game where Harry chases Horcruxes.&lt;/p&gt;

&lt;p&gt;The cost breakdown:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bedrock (LLM calls): 67% — $1.31/game&lt;/li&gt;
&lt;li&gt;Lambda (compute): 26% — $0.51/game&lt;/li&gt;
&lt;li&gt;DynamoDB (state): 7% — $0.13/game&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now imagine deploying this as an always-on interactive experience. Imagine scaling to 1,000 simultaneous games. The numbers get terrifying fast.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Four Fixes: An Optimization Ladder
&lt;/h2&gt;

&lt;p&gt;I didn't need fewer agents. I needed fewer &lt;em&gt;expensive decisions&lt;/em&gt;. Here's the optimization ladder pushing decisions DOWN from the costly LLM layer to cheaper alternatives.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Furuaenbmrr8xy8xjvdqm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Furuaenbmrr8xy8xjvdqm.png" alt=" " width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Fix 1: Bound the Problem (Constraint Pruning)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt; Harry saw 90 possible actions per turn (15 locations × 6 action types: search, attack, use_ally, investigate, fortify, retreat) and the LLM had to reason about which were valid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;After:&lt;/strong&gt; A constraint solver prunes invalid actions &lt;em&gt;before&lt;/em&gt; Harry's LLM sees them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_valid_actions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;harry&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;actions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;loc&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;locations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cooldown&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;         &lt;span class="c1"&gt;# not on cooldown
&lt;/span&gt;            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;usage_count&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;MAX_USES&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# not exhausted
&lt;/span&gt;                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;budget&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;           &lt;span class="c1"&gt;# has action budget
&lt;/span&gt;                    &lt;span class="n"&gt;actions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;actions&lt;/span&gt;  &lt;span class="c1"&gt;# typically 2-4 options, not 90
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; 90 options → 2-4 valid options. Harry's LLM never wastes tokens reasoning about locations on cooldown or abilities already spent. &lt;strong&gt;80% reduction in invalid reasoning tokens.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is where I coined the principle: &lt;strong&gt;"Fail Fast, Fail Free."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The constraint solver catches bad decisions &lt;em&gt;before they touch the LLM&lt;/em&gt;. An invalid action rejected by a 0.2ms Python function costs nothing. The same invalid action reasoned about by Claude for 3 seconds costs tokens, latency, and often a retry when post-inference validation fails.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fail fast = catch it early. Fail free = catch it before the meter starts running.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Fix 2: Replace Tokens with Math (Bayesian Inference)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt; Harry re-read 50 turns of narrative history (5,000 tokens) to figure out "where is the Horcrux probably located?"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Turn 1: Harry searched Hogwarts → negative signal
Turn 2: Harry searched Diagon Alley → positive signal  
Turn 3: Harry attacked Diagon Alley → decoy!
Turn 4: Voldemort relocated something...
... (50 turns of this = 5,000 tokens)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;After:&lt;/strong&gt; A Bayesian belief map computes probabilities &lt;em&gt;outside&lt;/em&gt; the LLM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HorcruxBeliefMap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;locations&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;locations&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;beliefs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;loc&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;locations&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;  &lt;span class="c1"&gt;# uniform prior
&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;update_on_signal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;positive&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;beliefs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*=&lt;/span&gt; &lt;span class="mf"&gt;3.0&lt;/span&gt;   &lt;span class="c1"&gt;# 3x more likely here
&lt;/span&gt;        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;negative&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;beliefs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*=&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;   &lt;span class="c1"&gt;# 10x less likely
&lt;/span&gt;        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;destroyed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;beliefs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;    &lt;span class="c1"&gt;# confirmed eliminated
&lt;/span&gt;        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;normalize&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;top_targets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;sorted_locs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;beliefs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;sorted_locs&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What Harry's LLM actually sees: &lt;code&gt;"top_target: Hogwarts (p=0.34), Azkaban (p=0.22)"&lt;/code&gt; = 15 tokens, not 5,000.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; 97% context reduction. Cost drops from $0.015 to effectively $0 for the belief computation. And Harry makes &lt;em&gt;better&lt;/em&gt; decisions because probabilities are more precise than narrative intuition.&lt;/p&gt;

&lt;p&gt;Another face of "Fail Fast, Fail Free" is if you can compute the answer with math ($0), why would you pay an LLM ($0.015) to infer it from narrative text?&lt;/p&gt;

&lt;h3&gt;
  
  
  Fix 3: Skip the LLM Call (Heuristic Decision Trees)
&lt;/h3&gt;

&lt;p&gt;Not every Voldemort decision needs a $200B parameter model. Some game situations have obvious optimal moves:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;voldemort_decide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# If Harry is one move from a real Horcrux → relocate (obvious)
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;harry_adjacent_to_horcrux&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;RelocateAction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;threatened_horcrux&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# If decoy budget available and Harry is confident → disrupt
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;decoy_budget&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nf"&gt;harry_entropy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;PlantDecoyAction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;harry_top_target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# If early game with high uncertainty → do nothing (save budget)
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;turn&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nf"&gt;harry_entropy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;3.0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;WaitAction&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Only genuinely complex situations need LLM
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;call_llm_for_strategy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; 60% of Voldemort's decisions handled with zero LLM cost. Only the genuinely strategic moments where multiple valid strategies compete, justify an inference call.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fix 4: Isolate the Expensive Layer (Architecture)
&lt;/h3&gt;

&lt;p&gt;The most impactful change was structural. I redesigned Horcrux Hunt so only &lt;strong&gt;2 of 8 modules&lt;/strong&gt; ever touch the LLM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FREE MODULES (6):
├── Game Engine         (rules, turn management)
├── Constraint Solver   (valid action computation)
├── Belief Manager      (Bayesian probability updates)
├── State Persistence   (DynamoDB read/write)
├── Validation Layer    (response format checking)
└── Metrics &amp;amp; Logging   (CloudWatch, dashboards)

EXPENSIVE MODULES (2):
├── Harry Strategic Layer    (genuinely uncertain decisions)
└── Voldemort Strategic Layer (only when heuristics can't decide)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Interface Boundary compresses context at the border between free and expensive:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Input to LLM:&lt;/strong&gt; 2,000+ tokens of raw game state → compressed to 55 tokens of AgentContext&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Output from LLM:&lt;/strong&gt; Validated immediately, rejected for free if invalid&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is "Fail Fast, Fail Free" as architecture: clear cost boundaries. Validation happens in the free zone. If something is going to fail, it fails in one of the 6 free modules, but never in the 2 expensive ones.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Results
&lt;/h2&gt;

&lt;p&gt;Same game. Same Harry. Same Voldemort. Same Claude Sonnet model. Radically different architecture:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0sgr3pg01f9o1dqa395g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0sgr3pg01f9o1dqa395g.png" alt=" " width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;th&gt;Change&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cost per game&lt;/td&gt;
&lt;td&gt;$1.95&lt;/td&gt;
&lt;td&gt;$0.35&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;-82%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Latency per turn&lt;/td&gt;
&lt;td&gt;12s&lt;/td&gt;
&lt;td&gt;3s&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;-75%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Harry win rate&lt;/td&gt;
&lt;td&gt;23%&lt;/td&gt;
&lt;td&gt;52%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;+29pp&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Timeout rate&lt;/td&gt;
&lt;td&gt;18%&lt;/td&gt;
&lt;td&gt;&amp;lt;3%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;-83%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retry rate&lt;/td&gt;
&lt;td&gt;15%&lt;/td&gt;
&lt;td&gt;&amp;lt;3%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;-80%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Annual cost at scale&lt;/td&gt;
&lt;td&gt;$588K&lt;/td&gt;
&lt;td&gt;$102K&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;-$486K&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Harry wins more, not because the model is smarter, but because he's reasoning over focused, relevant information instead of drowning in 6,000 tokens of noise. The audience sees 3-second turns instead of 12-second waits. The game is actually &lt;em&gt;fun&lt;/em&gt; to watch now.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Lesson
&lt;/h2&gt;

&lt;p&gt;The answer to "How many agents are too many?" isn't a number. It's a question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Is this decision worth an LLM call?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most of Voldemort's decisions weren't. Most of Harry's probability calculations weren't. Most of the validation logic wasn't. Once I stopped paying the LLM to discover things I already knew, the costs fell off a cliff.&lt;/p&gt;

&lt;p&gt;The Optimization Ladder:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Can a &lt;strong&gt;rule&lt;/strong&gt; handle this? (Free — constraints, cooldowns, budgets)&lt;/li&gt;
&lt;li&gt;Can a &lt;strong&gt;heuristic&lt;/strong&gt; handle this? (Nearly free — if/then game logic)&lt;/li&gt;
&lt;li&gt;Can &lt;strong&gt;math&lt;/strong&gt; handle this? (Cheap — Bayesian updates, entropy)&lt;/li&gt;
&lt;li&gt;Does this genuinely need an &lt;strong&gt;LLM&lt;/strong&gt;? (Expensive — but justified for true uncertainty)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Push every decision as far DOWN that ladder as it can go. &lt;strong&gt;Fail fast, fail free&lt;/strong&gt; at every layer.&lt;/p&gt;




&lt;p&gt;🚀 What's Next&lt;/p&gt;

&lt;p&gt;The bill is under control. But Harry's still losing.&lt;/p&gt;

&lt;p&gt;He searches the same location twice. He forgets signals from 3 turns ago. He contradicts his own belief map. The problem isn't cost anymore, it's memory masquerading as reasoning failure.&lt;/p&gt;

&lt;p&gt;→ &lt;a href="https://dev.to/royanannya/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8"&gt;Part 0: Fail Fast, Fail Free&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Read this blog to know more about the principle.&lt;/p&gt;

&lt;p&gt;→ &lt;a href="https://dev.to/blog/part-2-agent-memory"&gt;Part 2: Why Your Agent Forgets&lt;/a&gt; where I discover that 68% of Harry's "reasoning failures" are actually retrieval failures, and the fix is entropy math, not bigger models.&lt;/p&gt;

&lt;p&gt;Spoiler: I compressed Harry's context from 12,000 tokens to 340. Same LLM. Same prompts. Completely different agent.&lt;/p&gt;

&lt;p&gt;💬 Quick diagnostic for your agent:&lt;/p&gt;

&lt;p&gt;Run the same input 5 times. Does your agent give the same output every time?&lt;/p&gt;

&lt;p&gt;✅ Yes → You probably have a cost or integration problem (Part 1 or 3)&lt;br&gt;
❌ No → You definitely have a memory problem (next post)&lt;br&gt;
🤷 Haven't checked → ...that's the scariest answer of all&lt;/p&gt;

&lt;p&gt;Drop your answer below. I'll tell you exactly which post in this series has your fix. 👇&lt;/p&gt;

&lt;p&gt;🔖 Follow me to get Part 2 when it drops or keep refreshing your inference bill until you're motivated enough to read it. Your choice. 💸&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I am a Gen AI Developer Advocate &amp;amp; Architect. I built a multi-agent AI game to entertain a conference audience and accidentally created the most expensive stress test for multi-agent systems I'd ever seen. So. I adapted the classic "Fail Safe" and came up with "Fail Fast, Fail Free" after that $1,847 weekend taught me that the most expensive failure is one you discover too late.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>programming</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Are you building AI Agents? Then you need to look at this design principle!!</title>
      <dc:creator>Anannya Roy Chowdhury</dc:creator>
      <pubDate>Mon, 13 Jul 2026 05:53:53 +0000</pubDate>
      <link>https://dev.to/royanannya/are-you-building-ai-agents-then-you-need-to-look-at-this-design-principle-38fe</link>
      <guid>https://dev.to/royanannya/are-you-building-ai-agents-then-you-need-to-look-at-this-design-principle-38fe</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/aws/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8" class="crayons-story__hidden-navigation-link"&gt;"Fail Fast, Fail Free : The Design principle my multi-agent game was missing"&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;
          &lt;a class="crayons-logo crayons-logo--l" href="/aws"&gt;
            &lt;img alt="AWS logo" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F1726%2F2a73f1e6-7995-4348-ae37-44b064274c59.png" class="crayons-logo__image" width="320" height="320"&gt;
          &lt;/a&gt;

          &lt;a href="/royanannya" class="crayons-avatar  crayons-avatar--s absolute -right-2 -bottom-2 border-solid border-2 border-base-inverted  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3813086%2F9b30135b-af43-4b2d-80ba-cc780071faa5.png" alt="royanannya profile" class="crayons-avatar__image" width="800" height="800"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/royanannya" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Anannya Roy Chowdhury
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Anannya Roy Chowdhury
                
              
              &lt;div id="story-author-preview-content-3929167" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/royanannya" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3813086%2F9b30135b-af43-4b2d-80ba-cc780071faa5.png" class="crayons-avatar__image" alt="" width="800" height="800"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Anannya Roy Chowdhury&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

            &lt;span&gt;
              &lt;span class="crayons-story__tertiary fw-normal"&gt; for &lt;/span&gt;&lt;a href="/aws" class="crayons-story__secondary fw-medium"&gt;AWS&lt;/a&gt;
            &lt;/span&gt;
          &lt;/div&gt;
          &lt;a href="https://dev.to/aws/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jun 30&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/aws/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8" id="article-link-3929167"&gt;
          "Fail Fast, Fail Free : The Design principle my multi-agent game was missing"
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/aws"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;aws&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/agents"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;agents&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/systemdesign"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;systemdesign&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/aws/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/raised-hands-74b2099fd66a39f2d7eed9305ee0f4553df0eb7b4f11b01b6b1b499973048fe5.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;21&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/aws/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              8&lt;span class="hidden s:inline"&gt;&amp;nbsp;comments&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            10 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>I Built a Multi-Agent Game. One Missing Design Principle Broke Everything. Read about this below.</title>
      <dc:creator>Anannya Roy Chowdhury</dc:creator>
      <pubDate>Thu, 02 Jul 2026 02:06:58 +0000</pubDate>
      <link>https://dev.to/royanannya/i-built-a-multi-agent-game-one-missing-design-principle-broke-everything-read-about-this-below-p81</link>
      <guid>https://dev.to/royanannya/i-built-a-multi-agent-game-one-missing-design-principle-broke-everything-read-about-this-below-p81</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/aws/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8" class="crayons-story__hidden-navigation-link"&gt;"Fail Fast, Fail Free : The Design principle my multi-agent game was missing"&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;
          &lt;a class="crayons-logo crayons-logo--l" href="/aws"&gt;
            &lt;img alt="AWS logo" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F1726%2F2a73f1e6-7995-4348-ae37-44b064274c59.png" class="crayons-logo__image" width="320" height="320"&gt;
          &lt;/a&gt;

          &lt;a href="/royanannya" class="crayons-avatar  crayons-avatar--s absolute -right-2 -bottom-2 border-solid border-2 border-base-inverted  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3813086%2F9b30135b-af43-4b2d-80ba-cc780071faa5.png" alt="royanannya profile" class="crayons-avatar__image" width="800" height="800"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/royanannya" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Anannya Roy Chowdhury
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Anannya Roy Chowdhury
                
              
              &lt;div id="story-author-preview-content-3929167" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/royanannya" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3813086%2F9b30135b-af43-4b2d-80ba-cc780071faa5.png" class="crayons-avatar__image" alt="" width="800" height="800"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Anannya Roy Chowdhury&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

            &lt;span&gt;
              &lt;span class="crayons-story__tertiary fw-normal"&gt; for &lt;/span&gt;&lt;a href="/aws" class="crayons-story__secondary fw-medium"&gt;AWS&lt;/a&gt;
            &lt;/span&gt;
          &lt;/div&gt;
          &lt;a href="https://dev.to/aws/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jun 30&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/aws/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8" id="article-link-3929167"&gt;
          "Fail Fast, Fail Free : The Design principle my multi-agent game was missing"
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/aws"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;aws&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/agents"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;agents&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/systemdesign"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;systemdesign&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/aws/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/raised-hands-74b2099fd66a39f2d7eed9305ee0f4553df0eb7b4f11b01b6b1b499973048fe5.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;11&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/aws/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              6&lt;span class="hidden s:inline"&gt;&amp;nbsp;comments&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            10 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Anannya Roy Chowdhury</dc:creator>
      <pubDate>Wed, 01 Jul 2026 01:03:46 +0000</pubDate>
      <link>https://dev.to/royanannya/-2mg7</link>
      <guid>https://dev.to/royanannya/-2mg7</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/aws/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8" class="crayons-story__hidden-navigation-link"&gt;"Fail Fast, Fail Free : The Design principle my multi-agent game was missing"&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;
          &lt;a class="crayons-logo crayons-logo--l" href="/aws"&gt;
            &lt;img alt="AWS logo" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F1726%2F2a73f1e6-7995-4348-ae37-44b064274c59.png" class="crayons-logo__image" width="320" height="320"&gt;
          &lt;/a&gt;

          &lt;a href="/royanannya" class="crayons-avatar  crayons-avatar--s absolute -right-2 -bottom-2 border-solid border-2 border-base-inverted  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3813086%2F9b30135b-af43-4b2d-80ba-cc780071faa5.png" alt="royanannya profile" class="crayons-avatar__image" width="800" height="800"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/royanannya" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Anannya Roy Chowdhury
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Anannya Roy Chowdhury
                
              
              &lt;div id="story-author-preview-content-3929167" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/royanannya" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3813086%2F9b30135b-af43-4b2d-80ba-cc780071faa5.png" class="crayons-avatar__image" alt="" width="800" height="800"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Anannya Roy Chowdhury&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

            &lt;span&gt;
              &lt;span class="crayons-story__tertiary fw-normal"&gt; for &lt;/span&gt;&lt;a href="/aws" class="crayons-story__secondary fw-medium"&gt;AWS&lt;/a&gt;
            &lt;/span&gt;
          &lt;/div&gt;
          &lt;a href="https://dev.to/aws/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jun 30&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/aws/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8" id="article-link-3929167"&gt;
          "Fail Fast, Fail Free : The Design principle my multi-agent game was missing"
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/aws"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;aws&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/agents"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;agents&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/systemdesign"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;systemdesign&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/aws/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/raised-hands-74b2099fd66a39f2d7eed9305ee0f4553df0eb7b4f11b01b6b1b499973048fe5.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;11&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/aws/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              6&lt;span class="hidden s:inline"&gt;&amp;nbsp;comments&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            10 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>"Fail Fast, Fail Free : The Design principle my multi-agent AI was missing"</title>
      <dc:creator>Anannya Roy Chowdhury</dc:creator>
      <pubDate>Tue, 30 Jun 2026 04:18:53 +0000</pubDate>
      <link>https://dev.to/royanannya/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8</link>
      <guid>https://dev.to/royanannya/fail-fast-fail-free-the-design-principle-my-multi-agent-game-was-missing-4db8</guid>
      <description>&lt;p&gt;&lt;em&gt;This is an intro to "Multi-Agent Systems in Production: What They Don't Tell You" — a four-part series based on a game I built for my conference talks at AI Engineer Week, Conf42 LLM, AgentCon Bengaluru, and R/pharma GenAI. This introductory post defines the unifying principle behind everything that follows.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Most Expensive Bug I Ever Shipped
&lt;/h2&gt;

&lt;p&gt;The bug wasn't in my code. The logic was correct. The prompts were good. The model was state-of-the-art.&lt;/p&gt;

&lt;p&gt;The bug was &lt;em&gt;where&lt;/em&gt; my system failed.&lt;/p&gt;

&lt;p&gt;I built a multi-agent interactive game called "Horcrux Hunt" where two AI agents (Harry and Voldemort) battle live in front of an audience. Harry (Claude on Amazon Bedrock, Strands SDK) hunts Horcruxes hidden across 15 locations. Voldemort (heuristic-first adversary with LLM fallback) relocates them, plants decoys, and corrupts Harry's beliefs. The audience watches on a Streamlit dashboard as the hunt unfolds in real time. &lt;/p&gt;

&lt;p&gt;And then we ran it. One weekend event. &lt;strong&gt;$1,847 in AWS bills.&lt;/strong&gt; 12-second latency per turn. Audience waiting. Harry losing 77% of the time.&lt;/p&gt;

&lt;p&gt;When I dissected the failure, I found the same pattern everywhere:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The LLM, during Harry's move, reasoned about 90 possible actions. &lt;strong&gt;86 were invalid.&lt;/strong&gt; It spent 3 seconds and 2,000 tokens discovering what a 0.2ms constraint check could have told it for free.&lt;/li&gt;
&lt;li&gt;The Harry agent retrieved 5,000 tokens of history to make a decision. &lt;strong&gt;A 55-token probability score contained the same information.&lt;/strong&gt; But we loaded the full context first and compressed later — paying before checking.&lt;/li&gt;
&lt;li&gt;A tool call with invalid parameters hit the API, got a 400 error, retried twice. &lt;strong&gt;Client-side validation would have caught it in &amp;lt;1ms, before any call or game action was wasted.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;I added Hermione, Ron, and Dumbledore agents** to help Harry. These three agents independently queried the same guidelines, produced conflicting strategies, and Harry's win rate &lt;em&gt;dropped&lt;/em&gt; from 61% to 34%. &lt;strong&gt;A single priority check before execution would have caught it for free.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every expensive failure had the same shape: &lt;em&gt;the system knew it would fail, but discovered this too late. After tokens were spent, latency was burned, compute was consumed, and turns were wasted.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I started calling this pattern &lt;strong&gt;"failing slow, failing expensive."&lt;/strong&gt; And its opposite became my design principle:&lt;/p&gt;




&lt;h2&gt;
  
  
  Fail Fast, Fail Free.
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;If a decision is going to fail, make it fail &lt;em&gt;before&lt;/em&gt; it costs you anything.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's it. That's the principle.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fail fast&lt;/strong&gt; = catch it at the earliest possible checkpoint&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fail free&lt;/strong&gt; = catch it before the expensive meter starts running&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the Horcrux hunt game, the "meter" is different depending on context:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In &lt;strong&gt;cost&lt;/strong&gt; terms: an LLM call ($0.008-0.015 per failure) vs $0 for a constraint check resolving an invalid action&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;latency&lt;/strong&gt; terms: a 3-second inference call for an action the game rejects anyway vs a 0.2ms validation&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;game&lt;/strong&gt; terms: Harry wasting a turn on a cooldown location vs knowing instantly it's unavailable&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;coordination&lt;/strong&gt; terms: Four agents arguing for 9 seconds vs Harry deciding alone when entropy is low&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;reliability&lt;/strong&gt; terms: a retry loop burning tokens vs a pre-validated clean call&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The principle asks one question of every failure in your system: &lt;strong&gt;Could this have been caught earlier, cheaper, or both?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Almost always, the answer is yes.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Anatomy of a Free Failure
&lt;/h2&gt;

&lt;p&gt;What does a "free failure" actually look like? Here's the pattern for the game:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# EXPENSIVE failure (traditional):
# 1. Load full game history and Build full context (500ms, 2000 tokens)
# 2. Call LLM for decision (3000ms, $0.008)
# 3. Parse response (50ms) DETECTED HERE
# 4. Retry from step 1 (another $0.008)
# Total cost of failure: $0.016 + 3.5 seconds
&lt;/span&gt;
&lt;span class="c1"&gt;# FREE failure (fail fast, fail free):
# 1. Validate input ← FAILURE DETECTED HERE (0.2ms, $0)
# 2. (never reaches LLM)
# Total cost of failure: $0 + 0.2ms
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key insight: &lt;strong&gt;validation is nearly free. Inference is expensive. Move the checkpoint upstream.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This isn't just "input validation" in the traditional software engineering sense. In multi-agent production systems, there are &lt;em&gt;multiple layers&lt;/em&gt; where you can catch failures before they become expensive:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Layer 1: Constraint check     →  "Is this action even valid?"     → 0.2ms, $0
Layer 2: Entropy check        →  "Does this need LLM reasoning?"  → 0.5ms, $0
Layer 3: Schema validation    →  "Are these parameters correct?"  → 0.3ms, $0
Layer 4: Safety gate          →  "Is this output safe?"           → 1ms, $0
Layer 5: Priority resolution  →  "Do agents agree?"               → 2ms, $0
─────────────────────────────────────────────────────────────────────────────
Layer 6: LLM inference        →  "What should I do?"              → 3000ms, $0.008
Layer 7: API call             →  "Execute the action"             → 500ms, variable
Layer 8: Retry                →  "Try again"                      → 3500ms, $0.008+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Layers 1-5 are free. Layers 6-8 are expensive. &lt;strong&gt;Every failure you catch in Layers 1-5 is a failure that never reaches Layers 6-8.&lt;/strong&gt; That's "fail fast, fail free."&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Matters Specifically for Multi-Agent Systems
&lt;/h2&gt;

&lt;p&gt;In a single-agent system, a failure costs you one LLM call. Annoying but survivable.&lt;/p&gt;

&lt;p&gt;In a multi-agent system, failures &lt;strong&gt;compound&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 agent  failing = 1 retry × 1 inference cost
3 agents failing = retries × context replay × coordination overhead × cascading delays
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When Harry produces invalid output, Voldemort receives it, reasons about it (paying tokens), produces its own output based on garbage, Executor Agent receives THAT... by the time you detect the failure, you've paid three inference calls, contaminated shared state, and need to rewind everything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In multi-agent systems, a failure that isn't caught early becomes a failure that multiplies.&lt;/strong&gt; This is why "&lt;strong&gt;fail fast, fail free&lt;/strong&gt;" isn't just a nice optimization. It's architecturally critical.&lt;/p&gt;

&lt;p&gt;The cost of late detection in multi-agent systems:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Where failure is caught&lt;/th&gt;
&lt;th&gt;Cost in single-agent&lt;/th&gt;
&lt;th&gt;Cost in 3-agent system&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Before LLM call (Layer 1-5)&lt;/td&gt;
&lt;td&gt;$0&lt;/td&gt;
&lt;td&gt;$0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;After 1 LLM call (Layer 6)&lt;/td&gt;
&lt;td&gt;$0.008&lt;/td&gt;
&lt;td&gt;$0.008&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;After cascading to other agents&lt;/td&gt;
&lt;td&gt;$0.008&lt;/td&gt;
&lt;td&gt;$0.024 + state rollback&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;After reaching the user&lt;/td&gt;
&lt;td&gt;$0.008&lt;/td&gt;
&lt;td&gt;Incalculable&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The multiplication factor is why "fail fast, fail free" becomes an architectural principle for my multi-agent game and other production AI systems, not just a coding best practice.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Four Faces of Fail Fast, Fail Free
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fctuas9ghifjec7w2pprc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fctuas9ghifjec7w2pprc.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This principle shows up differently depending on which failure mode you're facing. Here's a preview of how it manifests across the four parts of this series:&lt;/p&gt;

&lt;h3&gt;
  
  
  🔥 Cost: Prune Before Reasoning (Part 1)
&lt;/h3&gt;

&lt;p&gt;The LLM doesn't need to reason about invalid options.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Fail fast: constraint solver runs BEFORE LLM
&lt;/span&gt;&lt;span class="n"&gt;valid_actions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;constraint_solver&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 0.2ms, $0
# 90 options → 4 valid actions
# The LLM never sees the 86 invalid ones
# 86 failures caught for free
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If 86 of Harry's 90 possible actions are invalid (exhausted location. spent powers), letting the LLM discover this wastes 95% of its reasoning budget. A constraint solver makes those 86 failures free, they never reach the meter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The mantra:&lt;/strong&gt; Don't let the LLM think about things you already know the answer to.&lt;/p&gt;

&lt;h3&gt;
  
  
  🧠 Memory: Gate Before Retrieving (Part 2)
&lt;/h3&gt;

&lt;p&gt;Not every decision deserves full context retrieval, in my case the full 5000 tokens as history for Harry's next move.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Fail fast: entropy check BEFORE retrieval
&lt;/span&gt;&lt;span class="n"&gt;entropy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculate_entropy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;belief_map&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;entropy&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Harry already knows where the Horcrux is
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;heuristic_decision&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# 0 tokens, $0
# Only uncertain decisions justify context retrieval cost
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When entropy is low (the agent, using the bayesian belief map, is already confident of a move), sending context of 50 turns to the LLM is waste. The entropy check is a fail-fast gate: "Do I even need to spend tokens on this decision?" 60% of the time, the answer is no. Those decisions become free.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The mantra:&lt;/strong&gt; Check whether you need to think before you start thinking.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔌 Integration: Validate Before Calling (Part 3)
&lt;/h3&gt;

&lt;p&gt;Client-side schema validation catches bad parameters for free.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Fail fast: JSON Schema validation BEFORE API call
&lt;/span&gt;&lt;span class="n"&gt;errors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;jsonschema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tool_schema&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# &amp;lt;1ms, $0
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;fix_params&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# self-correct without any call
# Only valid calls reach the API
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A classic example of my game validation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Fail fast: schema validation BEFORE game action executes
&lt;/span&gt;&lt;span class="n"&gt;errors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;validate_tool_call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;search_location&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;location&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;hogwarts&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;game_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cooldown&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;hogwarts&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;ToolError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hogwarts on cooldown for 2 turns&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# &amp;lt;1ms, $0
# Only valid, available actions consume game budget
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When Harry tries to search a location on cooldown (from Game Theory - a mechanism that restricts immediate retaliation or repeated actions), catching it at validation (free, &amp;lt;1ms) is infinitely better than catching it after an LLM inference + game execution + failure + retry. So what's better than to use MCP here. MCP's killer feature isn't the protocol itself — it's that schema contracts between server and client enable &lt;em&gt;free validation&lt;/em&gt;. Every parameter error caught in &amp;lt;1ms is a retry that never happens. At 2.3 retries per request (our pre-MCP baseline), this is massive: 91% reduction in retries, purely by moving the failure checkpoint upstream.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The mantra:&lt;/strong&gt; The cheapest API call is the one you never make.&lt;/p&gt;

&lt;h3&gt;
  
  
  🏥 Coordination: Veto Before Executing (Part 4)
&lt;/h3&gt;

&lt;p&gt;In regulated systems, unsafe responses must fail at review, not at the execution step. For example, in my horcrux game, when Hermione and Dumbledore disagree, we need to resolve it &lt;em&gt;before&lt;/em&gt; Harry acts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Fail fast: priority resolution BEFORE team executes
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;hermione&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;recommends&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;attack_azkaban&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;dumbledore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;warns&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;trap_detected&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# Priority: Dumbledore's safety assessment OVERRIDES Hermione's analysis
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;harry_defend&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# resolved in &amp;lt;2ms, no cascading confusion
# Only aligned, conflict-free strategies reach execution
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the Safety analysis vetoes an unsafe action, that "failure" is free and is a &amp;lt;2ms activity. The alternative (delivering an unsafe action using tokens and multiple retries) is infinitely expensive. So, "fail fast, fail free" becomes "validate early, harm never."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The mantra:&lt;/strong&gt; The safest failure is the one that never reaches the executor.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Optimization Ladder (Reframed)
&lt;/h2&gt;

&lt;p&gt;Here, I'll introduce the "Optimization Ladder" — a framework for pushing decisions down from expensive layers to cheap ones. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi063dd8b807snse4k4xn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi063dd8b807snse4k4xn.png" alt=" " width="800" height="667"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Reframed through "Fail Fast, Fail Free," it becomes a failure checkpoint ladder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CHEAPEST (try first):
├── Rules &amp;amp; Constraints     → Can I rule this out for free?
├── Heuristics              → Is the answer obvious?
├── Math &amp;amp; Statistics       → Can I compute instead of infer?
├── Compressed Inference    → Can I think with less context?
MOST EXPENSIVE (last resort):
└── Full LLM Reasoning      → Only genuinely uncertain decisions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each layer is a checkpoint. Each checkpoint catches failures before they cascade to the layer below. The system only pays for inference on decisions that survive every free checkpoint above which turns out to be about 20-40% of turns.&lt;/p&gt;

&lt;p&gt;The other 60-80%? &lt;strong&gt;Free.&lt;/strong&gt; In my game, Harry acts on constraints, entropy gates, heuristics, and math. All at zero token cost. And counterintuitively, his win rate &lt;em&gt;improved&lt;/em&gt; because less noise = better decisions.&lt;/p&gt;




&lt;h2&gt;
  
  
  How to Apply This Tomorrow
&lt;/h2&gt;

&lt;p&gt;You don't need to redesign your system. Start with one question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Where in my pipeline do I first discover that something is wrong?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then ask: &lt;strong&gt;"Could I have discovered that one step earlier?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Repeat until the answer is "no" or "the failure checkpoint is already free."&lt;/p&gt;

&lt;p&gt;Practical starting points:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Add input validation before every LLM call.&lt;/strong&gt; What percentage of your prompts contain information that makes the answer predetermined? What percentage of your agent's reasoning leads to invalid actions? That's your "free failure" opportunity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Add an entropy/confidence check before retrieval.&lt;/strong&gt; How often does your agent retrieve context it doesn't need? That's wasted tokens.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Add schema validation before every tool call.&lt;/strong&gt; What's your retry rate? Each retry = full token cost. Multiply that by your average token cost. That's what free validation saves you.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Add a safety/priority check before every multi-agent output.&lt;/strong&gt; How often do your agents disagree? Each disagreement caught at orchestration is a contradiction that never reaches the user.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  The Series Roadmap
&lt;/h2&gt;

&lt;p&gt;This blog defines the principle. The next four show it in action — all through the lens of building, breaking, and fixing Horcrux Hunt:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part&lt;/th&gt;
&lt;th&gt;Problem&lt;/th&gt;
&lt;th&gt;"Fail Fast, Fail Free" Manifestation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;a href="https://dev.to/blog/part-1-cost"&gt;Part 1: Cost&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$1,847 bill for a weekend game, 12s latency, 23% win rate.&lt;/td&gt;
&lt;td&gt;Prune invalid actions BEFORE inference&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;a href="https://dev.to/blog/part-2-memory"&gt;Part 2: Memory&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;77% failure rate, perfect reasoning&lt;/td&gt;
&lt;td&gt;Gate retrieval by entropy BEFORE loading context&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;a href="https://dev.to/blog/part-3-mcp"&gt;Part 3: Integration&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Wrong tool, wrong move&lt;/td&gt;
&lt;td&gt;Validate parameters BEFORE making API calls&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;a href="https://dev.to/blog/part-4-coordination"&gt;Part 4: Coordination&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Added 3 agents. They Fight. Win rate DROPPED to 34%.&lt;/td&gt;
&lt;td&gt;Safety veto BEFORE delivering output&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each part tells a story, shows the failure, explains the fix, and proves the results. But now you know the common thread: every fix is a version of the same principle applied at a different layer.&lt;/p&gt;




&lt;h2&gt;
  
  
  One More Thing
&lt;/h2&gt;

&lt;p&gt;There's a beautiful symmetry here. "Fail fast, fail free" has existed in software engineering for decades — circuit breakers, input validation, type systems, contract testing. We know this principle.&lt;/p&gt;

&lt;p&gt;But somewhere in the excitement of LLMs, we forgot it. We started building systems where the first line of defense is a $200-billion-parameter model. We made inference the validator instead of the validated. We let Harry reason about every possibility instead of telling him which possibilities were already impossible.&lt;/p&gt;

&lt;p&gt;Multi-agent systems make this mistake catastrophically expensive because failures compound across agents. But the fix is the same fix we've always known:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't let expensive things discover what cheap things already know.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In my Horcrux Hunt game terms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Don't let Harry &lt;strong&gt;reason&lt;/strong&gt; about locations on cooldown (constraints know this)&lt;/li&gt;
&lt;li&gt;Don't let Harry &lt;strong&gt;retrieve&lt;/strong&gt; history when he's already confident (entropy knows this)&lt;/li&gt;
&lt;li&gt;Don't let Harry &lt;strong&gt;attempt&lt;/strong&gt; actions with invalid parameters (validation knows this)&lt;/li&gt;
&lt;li&gt;Don't let the &lt;strong&gt;team argue&lt;/strong&gt; when priority rules are clear (the mediator knows this)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check before you call. Validate before you execute. Prune before you reason. Gate before you retrieve. Veto before you deliver.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fail fast. Fail free.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 What's Next
&lt;/h2&gt;

&lt;p&gt;Harry spent $1,847 learning this lesson in one weekend. You can learn it for free...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;→ &lt;a href="https://dev.to/blog/part-1-cost"&gt;Part 1: The $1,847 Weekend&lt;/a&gt;&lt;/strong&gt; where the game goes live, the bill arrives, and I discover that 86 of 90 actions Harry reasoned about were already impossible (releasing soon).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you've ever watched your agent burn tokens on decisions a Python function could have handled, this one's for you.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;💬 I'm curious — what's your agent's retry rate right now?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Drop it in the comments. If it's above 5%, you're probably failing slow and failing expensive somewhere in your pipeline. I'll reply with which Part (1-4) has your fix.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔖 Bookmark this series&lt;/strong&gt; if you're building agents in production — each post drops one principle that saved me $576K/year in inference costs. Or just watch your monthly bill and you'll know when you need them.* 😏&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I am a GenAI Developer Advocate and Architect. I adapted the classic 'Fail safe' principle into what I call 'Fail Fast, Fail Free' after spending too much money on multi-agent systems that discovered their failures too late. I am now on a mission to make every failure in all my systems free or at least cheaper than my rent.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>systemdesign</category>
      <category>programming</category>
    </item>
    <item>
      <title>Read how Strands SDK can help you build AI Agents with practically low code!</title>
      <dc:creator>Anannya Roy Chowdhury</dc:creator>
      <pubDate>Mon, 01 Jun 2026 11:48:21 +0000</pubDate>
      <link>https://dev.to/royanannya/-4ia8</link>
      <guid>https://dev.to/royanannya/-4ia8</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/royanannya/i-let-an-ai-plan-my-vacation-heres-what-it-built-4b5h" class="crayons-story__hidden-navigation-link"&gt;I Let an AI Plan My Vacation (Here's What It Built)&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/royanannya" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3813086%2F9b30135b-af43-4b2d-80ba-cc780071faa5.png" alt="royanannya profile" class="crayons-avatar__image" width="800" height="800"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/royanannya" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Anannya Roy Chowdhury
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Anannya Roy Chowdhury
                
              
              &lt;div id="story-author-preview-content-3717681" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/royanannya" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3813086%2F9b30135b-af43-4b2d-80ba-cc780071faa5.png" class="crayons-avatar__image" alt="" width="800" height="800"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Anannya Roy Chowdhury&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/royanannya/i-let-an-ai-plan-my-vacation-heres-what-it-built-4b5h" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;May 27&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/royanannya/i-let-an-ai-plan-my-vacation-heres-what-it-built-4b5h" id="article-link-3717681"&gt;
          I Let an AI Plan My Vacation (Here's What It Built)
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/aws"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;aws&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/machinelearning"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;machinelearning&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/python"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;python&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/royanannya/i-let-an-ai-plan-my-vacation-heres-what-it-built-4b5h" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/fire-f60e7a582391810302117f987b22a8ef04a2fe0df7e3258a5f49332df1cec71e.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/raised-hands-74b2099fd66a39f2d7eed9305ee0f4553df0eb7b4f11b01b6b1b499973048fe5.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;9&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/royanannya/i-let-an-ai-plan-my-vacation-heres-what-it-built-4b5h#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            6 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>I Let an AI Plan My Vacation (Here's What It Built)</title>
      <dc:creator>Anannya Roy Chowdhury</dc:creator>
      <pubDate>Wed, 27 May 2026 14:45:00 +0000</pubDate>
      <link>https://dev.to/royanannya/i-let-an-ai-plan-my-vacation-heres-what-it-built-4b5h</link>
      <guid>https://dev.to/royanannya/i-let-an-ai-plan-my-vacation-heres-what-it-built-4b5h</guid>
      <description>&lt;h2&gt;
  
  
  I Had 47 Browser Tabs Open. So I Built an AI Travel Agent with &lt;a href="https://strandsagents.com/" rel="noopener noreferrer"&gt;Strands SDK&lt;/a&gt; + &lt;a href="https://aws.amazon.com/bedrock/?trk=be7b5579-904d-4ab5-808c-91e14f22671e&amp;amp;sc_channel=el" rel="noopener noreferrer"&gt;Amazon Bedrock&lt;/a&gt; ✈️
&lt;/h2&gt;

&lt;p&gt;Okay, so real talk.&lt;/p&gt;

&lt;p&gt;I had &lt;strong&gt;47 browser tabs&lt;/strong&gt; open.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;47.....&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Flights on a Flights App. Hotels on a Booking website. Weather on some sketchy website that was 40% ads. A spreadsheet I made at 11 PM that somehow had &lt;strong&gt;three separate columns all labeled "maybe hotel??"&lt;/strong&gt; and one row that just said:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"check vibes"&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;All I wanted was to plan a week-long trip to Thailand.&lt;/p&gt;

&lt;p&gt;And then — because I am a developer, and developers solve problems with code even when they absolutely should not — I closed all 47 tabs, opened &lt;a href="https://kiro.dev/?trk=be7b5579-904d-4ab5-808c-91e14f22671e&amp;amp;sc_channel=el" rel="noopener noreferrer"&gt;Kiro's&lt;/a&gt; spec-driven mode, and said:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Fine. I'll build the travel agent myself with Strands SDK."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Two hours later, I typed one sentence into my chat window and got back:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Flights&lt;/li&gt;
&lt;li&gt;Hotels&lt;/li&gt;
&lt;li&gt;Weather warnings&lt;/li&gt;
&lt;li&gt;A complete 7-day itinerary&lt;/li&gt;
&lt;li&gt;Budget breakdowns&lt;/li&gt;
&lt;li&gt;Packing recommendations&lt;/li&gt;
&lt;li&gt;VISA options&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And honestly?&lt;/p&gt;

&lt;p&gt;I haven’t touched that spreadsheet since.&lt;/p&gt;

&lt;p&gt;So let’s build the thing. 👇&lt;/p&gt;




&lt;h1&gt;
  
  
  Wait… What Even &lt;em&gt;Is&lt;/em&gt; Strands SDK?
&lt;/h1&gt;

&lt;p&gt;Before we dive in:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://strandsagents.com/" rel="noopener noreferrer"&gt;Strands&lt;/a&gt; SDK&lt;/strong&gt; is &lt;a href="https://aws.amazon.com/?trk=be7b5579-904d-4ab5-808c-91e14f22671e&amp;amp;sc_channel=el" rel="noopener noreferrer"&gt;AWS’s&lt;/a&gt; open-source Python framework for building AI agents.&lt;/p&gt;

&lt;p&gt;Think of it like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You write Python functions (&lt;strong&gt;tools&lt;/strong&gt;)&lt;/li&gt;
&lt;li&gt;Add a &lt;code&gt;@tool&lt;/code&gt; decorator&lt;/li&gt;
&lt;li&gt;Connect it to a model on Amazon Bedrock&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The model decides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;which tools to call&lt;/li&gt;
&lt;li&gt;in what order&lt;/li&gt;
&lt;li&gt;with what inputs&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s… basically it.&lt;/p&gt;

&lt;p&gt;No YAML facades.&lt;br&gt;
No 400-page orchestration configs.&lt;br&gt;
No dependency graphs that look like a subway map.&lt;/p&gt;

&lt;p&gt;Just Python functions and an LLM smart enough to use them.&lt;/p&gt;

&lt;p&gt;Here’s the mental model that helped me:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your Agent = A Smart Intern
Your Tools = What the Intern Can Do
Your Prompt = The Instructions
Bedrock = The Intern's Brain
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Except this intern:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;never misses deadlines&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;10/10 would hire again.&lt;/p&gt;




&lt;h1&gt;
  
  
  What We’re Building
&lt;/h1&gt;

&lt;p&gt;Our AI travel planner should:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✈️ Find flights&lt;/li&gt;
&lt;li&gt;🏨 Find hotels&lt;/li&gt;
&lt;li&gt;🌦️ Check weather&lt;/li&gt;
&lt;li&gt;📋 Check Budgets and Build a full itinerary&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One agent.&lt;br&gt;
Four tools.&lt;br&gt;
One prompt.&lt;/p&gt;

&lt;p&gt;Done.&lt;/p&gt;


&lt;h1&gt;
  
  
  Architecture Overview
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ehc38fys22gl8gg0htv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ehc38fys22gl8gg0htv.png" alt=" " width="800" height="803"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Stack Used
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://strandsagents.com/" rel="noopener noreferrer"&gt;Strands SDK&lt;/a&gt;&lt;/strong&gt; → Agent framework&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://aws.amazon.com/bedrock/?trk=be7b5579-904d-4ab5-808c-91e14f22671e&amp;amp;sc_channel=el" rel="noopener noreferrer"&gt;Amazon Bedrock&lt;/a&gt;&lt;/strong&gt; → Claude 3.5 Sonnet&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://aws.amazon.com/lambda/?trk=be7b5579-904d-4ab5-808c-91e14f22671e&amp;amp;sc_channel=el" rel="noopener noreferrer"&gt;AWS Lambda&lt;/a&gt;&lt;/strong&gt; → Tool execution&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://aws.amazon.com/secrets-manager/?trk=be7b5579-904d-4ab5-808c-91e14f22671e&amp;amp;sc_channel=el" rel="noopener noreferrer"&gt;Secrets Manager&lt;/a&gt;&lt;/strong&gt; → API keys&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://aws.amazon.com/s3/?trk=be7b5579-904d-4ab5-808c-91e14f22671e&amp;amp;sc_channel=el" rel="noopener noreferrer"&gt;S3&lt;/a&gt;&lt;/strong&gt; → Save itineraries&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://aws.amazon.com/cloudwatch/?trk=be7b5579-904d-4ab5-808c-91e14f22671e&amp;amp;sc_channel=el" rel="noopener noreferrer"&gt;CloudWatch&lt;/a&gt;&lt;/strong&gt; → Logging &amp;amp; observability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Yes, this is production-friendly.&lt;/p&gt;

&lt;p&gt;We’ll get there.&lt;/p&gt;


&lt;h1&gt;
  
  
  Step 0 — Setup
&lt;/h1&gt;

&lt;p&gt;Install dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;strands-agents strands-agents-tools boto3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enable &lt;strong&gt;Claude 3.5 Sonnet&lt;/strong&gt; inside Amazon Bedrock.&lt;/p&gt;

&lt;p&gt;Takes ~2 minutes.&lt;/p&gt;




&lt;h1&gt;
  
  
  🚨 Please Don’t Hardcode API Keys
&lt;/h1&gt;

&lt;p&gt;I know.&lt;/p&gt;

&lt;p&gt;You’re “just testing.”&lt;/p&gt;

&lt;p&gt;That API key &lt;em&gt;will&lt;/em&gt; end up in a public GitHub repo eventually.&lt;/p&gt;

&lt;p&gt;And then you will land up with a bill that burns your wallet.&lt;/p&gt;

&lt;p&gt;Use &lt;strong&gt;AWS Secrets Manager&lt;/strong&gt; instead.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_secret&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;secret_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Fetch API keys securely from AWS Secrets Manager.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

    &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;secretsmanager&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;region_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;us-east-1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_secret_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;SecretId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;secret_name&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SecretString&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;api_key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One function call.&lt;br&gt;
Sleep peacefully.&lt;/p&gt;


&lt;h1&gt;
  
  
  Tool #1 — Search Flights ✈️
&lt;/h1&gt;

&lt;p&gt;One thing that blew my mind about Strands:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Your docstring is part of the prompt.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Not for developers. For the model.&lt;/p&gt;

&lt;p&gt;The LLM reads your tool descriptions to decide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;when to call them&lt;/li&gt;
&lt;li&gt;how to call them&lt;/li&gt;
&lt;li&gt;what arguments to pass&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Good docstrings = smart agents.&lt;br&gt;
Bad docstrings = chaos.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;strands&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;tool&lt;/span&gt;

&lt;span class="nd"&gt;@tool&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;search_flights&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;departure_date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;return_date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;num_passengers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Search for available flights between cities.

    Returns:
    - airline
    - price
    - duration
    - stops
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

    &lt;span class="n"&gt;api_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_secret&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;travel-agent/flight-api-key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;flights&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;airline&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Thai Airways&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;price_per_person&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;510&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;stops&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;vibe&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Direct. Fancy. Worth it.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;airline&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Indigo&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;price_per_person&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;440&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;stops&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;vibe&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;One stop. Still emotionally stable.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yes, I added a &lt;code&gt;"vibe"&lt;/code&gt; field.&lt;/p&gt;

&lt;p&gt;No, the model doesn’t need it.&lt;/p&gt;

&lt;p&gt;Yes, it made me happy and my decision making, faster....&lt;/p&gt;




&lt;h1&gt;
  
  
  Tool #2 — Hotels That Aren’t Secretly Hostels 🏨
&lt;/h1&gt;

&lt;p&gt;You know what I hate?&lt;/p&gt;

&lt;p&gt;The hotel listing that says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"$89/night!"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And then somehow becomes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;$89 base price&lt;/li&gt;
&lt;li&gt;taxes&lt;/li&gt;
&lt;li&gt;resort fee&lt;/li&gt;
&lt;li&gt;“service charge”&lt;/li&gt;
&lt;li&gt;“convenience fee”&lt;/li&gt;
&lt;li&gt;emotional damage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My tool doesn’t do that.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nd"&gt;@tool&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;search_hotels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;check_in&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;check_out&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;budget_per_night&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Search hotels within budget.
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;hotels&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Veranda Resort&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;price_per_night&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mi"&gt;155&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;rating&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;4.8&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Pacific Club Hotel&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;price_per_night&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;rating&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;4.5&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;],&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;note&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;No hidden fees. Unlike some websites.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Tool #3 — Weather Check 🌧️
&lt;/h1&gt;

&lt;p&gt;Because packing goggles for Northern lights was a character-building experience I never want again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nd"&gt;@tool&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_weather&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;travel_month&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Get weather info and packing advice.
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;avg_temp_celsius&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;conditions&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Mild with dry heat&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;packing_must_haves&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Light coloured t-shirts&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;beach flip flops&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Umbrella&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sunscreen&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tiny tool. Massive usefulness.&lt;/p&gt;




&lt;h1&gt;
  
  
  Tool #4 — Build the Itinerary 📋
&lt;/h1&gt;

&lt;p&gt;This is where everything comes together.&lt;/p&gt;

&lt;p&gt;Flights ✅&lt;br&gt;
Hotels ✅&lt;br&gt;
Weather ✅&lt;/p&gt;

&lt;p&gt;Now the agent can finally build a realistic itinerary.&lt;/p&gt;

&lt;p&gt;And yes — we save it to S3.&lt;/p&gt;

&lt;p&gt;Because my Notes app cannot be trusted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;

&lt;span class="nd"&gt;@tool&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;build_itinerary&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;duration_days&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;interests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;budget_remaining&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Build a day-by-day itinerary.
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

    &lt;span class="n"&gt;itinerary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;destination&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;days&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;duration_days&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;interests&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;interests&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;daily_plan&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;day&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;theme&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Land and Eat Immediately&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;day&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;theme&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Markets and Sunset Beach Walks&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;s3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;s3&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;Bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;travel-itineraries&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;Key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;thai-trip.json&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;Body&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;itinerary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;itinerary&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Assemble the Agent
&lt;/h1&gt;

&lt;p&gt;Now the fun part.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;strands&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Agent&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;strands.models&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BedrockModel&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;BedrockModel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;anthropic.claude-3-5-sonnet&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;region_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;us-east-1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;temperature&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.3&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;SYSTEM_PROMPT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
You are a smart AI travel planner.

Always:
1. Search flights first
2. Search hotels second
3. Check weather
4. Build itinerary for given budget last
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="n"&gt;travel_agent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Agent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;system_prompt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;SYSTEM_PROMPT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="n"&gt;search_flights&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;search_hotels&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;get_weather&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;build_itinerary&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;travel_agent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Plan a 5-day Thailand trip for 2 people under $3000.
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Terminal Output
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Tool Call] search_flights
✓ Thai Airways selected

[Tool Call] search_hotels
✓ Veranda Resort selected

[Tool Call] get_weather
✓ Mild weather detected

[Tool Call] build_itinerary
✓ Saved to S3

━━━━━━━━━━━━━━━━━━
YOUR THAILAND TRIP
━━━━━━━━━━━━━━━━━━

Flights:   $1020
Hotel:     $775
Activities: $1200

TOTAL:     $2995 ✅
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That &lt;code&gt;✅ Under budget&lt;/code&gt; hit different.&lt;/p&gt;




&lt;h1&gt;
  
  
  Production Lessons (Learned the Hard Way)
&lt;/h1&gt;

&lt;p&gt;Here’s the honest truth:&lt;/p&gt;

&lt;p&gt;Your local demo is &lt;strong&gt;not&lt;/strong&gt; your production system.&lt;/p&gt;

&lt;p&gt;Things that &lt;em&gt;will&lt;/em&gt; hurt you eventually:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem&lt;/th&gt;
&lt;th&gt;Fix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hardcoded keys&lt;/td&gt;
&lt;td&gt;Secrets Manager&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Infinite tool loops&lt;/td&gt;
&lt;td&gt;Max tool-call limits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No observability&lt;/td&gt;
&lt;td&gt;CloudWatch logging&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Surprise Bedrock bill&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;max_tokens&lt;/code&gt; + alarms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Zero error handling&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;try/except&lt;/code&gt; everywhere&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Unsafe prompts&lt;/td&gt;
&lt;td&gt;Bedrock Guardrails&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  Add Logging with CloudWatch
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;logging&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;strands.handlers&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CallbackHandler&lt;/span&gt;

&lt;span class="n"&gt;logger&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getLogger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;travel-agent&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LoggingHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CallbackHandler&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;on_tool_call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;tool_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;tool_input&lt;/span&gt;
    &lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Calling &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;tool_name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;on_error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the difference between:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“cool demo”&lt;/li&gt;
&lt;li&gt;and “actual software”&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  My Biggest Takeaways
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1. Your Docstrings Matter More Than You Think
&lt;/h2&gt;

&lt;p&gt;The model uses them as instructions.&lt;/p&gt;

&lt;p&gt;Treat them seriously.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Tool Order Matters
&lt;/h2&gt;

&lt;p&gt;Without ordering rules, my agent built itineraries before knowing hotel costs.&lt;/p&gt;

&lt;p&gt;Beautiful plans. Completely wrong budget.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Lower Temperature = Better Planning
&lt;/h2&gt;

&lt;p&gt;High temperature is great for creativity.&lt;/p&gt;

&lt;p&gt;Not for budgeting.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Persist Everything
&lt;/h2&gt;

&lt;p&gt;S3. DynamoDB. Databases.&lt;/p&gt;

&lt;p&gt;Conversation memory disappears eventually.&lt;/p&gt;

&lt;p&gt;Your data shouldn’t.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. The Demo → Production Gap Is Real
&lt;/h2&gt;

&lt;p&gt;Prototypes and demos are magical.&lt;/p&gt;

&lt;p&gt;Production systems are where reality shows up with a baseball bat.&lt;/p&gt;

&lt;p&gt;Build responsibly.&lt;/p&gt;




&lt;h1&gt;
  
  
  FAQ
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Do I Need a Strands Certification?
&lt;/h2&gt;

&lt;p&gt;Nope.&lt;/p&gt;

&lt;p&gt;Just:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python&lt;/li&gt;
&lt;li&gt;Bedrock access&lt;/li&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s enough to start.&lt;/p&gt;




&lt;h2&gt;
  
  
  Can I Use Other Models?
&lt;/h2&gt;

&lt;p&gt;Absolutely.&lt;/p&gt;

&lt;p&gt;Swap Claude for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Llama&lt;/li&gt;
&lt;li&gt;Mistral&lt;/li&gt;
&lt;li&gt;Titan&lt;/li&gt;
&lt;li&gt;Anything available on Bedrock&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  My Agent Calls Tools in Weird Orders
&lt;/h2&gt;

&lt;p&gt;Fix your system prompt.&lt;/p&gt;

&lt;p&gt;Be explicit.&lt;/p&gt;

&lt;p&gt;LLMs love explicit instructions.&lt;/p&gt;




&lt;h1&gt;
  
  
  What’s Next?
&lt;/h1&gt;

&lt;p&gt;You can extend this into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🧠 Memory with &lt;a href="https://aws.amazon.com/dynamodb/?trk=be7b5579-904d-4ab5-808c-91e14f22671e&amp;amp;sc_channel=el" rel="noopener noreferrer"&gt;DynamoDB&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;💬 Slack bots&lt;/li&gt;
&lt;li&gt;🤖 Multi-agent orchestration&lt;/li&gt;
&lt;li&gt;🏭 &lt;a href="https://aws.amazon.com/bedrock/agentcore/?trk=be7b5579-904d-4ab5-808c-91e14f22671e&amp;amp;sc_channel=el" rel="noopener noreferrer"&gt;Bedrock AgentCore&lt;/a&gt; deployments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s where things get really interesting.&lt;/p&gt;




&lt;p&gt;I started this journey with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;47 browser tabs&lt;/li&gt;
&lt;li&gt;one broken spreadsheet&lt;/li&gt;
&lt;li&gt;and travel-planning rage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I ended it with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a functioning AI travel agent&lt;/li&gt;
&lt;li&gt;a Thailand itinerary&lt;/li&gt;
&lt;li&gt;and a permanently closed spreadsheet&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Honestly?&lt;/p&gt;

&lt;p&gt;Worth it.&lt;/p&gt;




&lt;p&gt;If you enjoyed this post:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❤️ Drop a reaction&lt;/li&gt;
&lt;li&gt;🔁 Share it with another developer&lt;/li&gt;
&lt;li&gt;👀 Follow for more AI agent tutorials&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And if you build something cool with Strands SDK — I genuinely want to see it. Hit the comments box or reach out over &lt;a href="https://www.linkedin.com/in/royanannya/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;. I work for AWS and love building and exchanging views on AI!&lt;/p&gt;

&lt;p&gt;Happy building. ✈️&lt;/p&gt;

</description>
      <category>ai</category>
      <category>aws</category>
      <category>machinelearning</category>
      <category>python</category>
    </item>
    <item>
      <title>Why your Production Retreival-Augmented-Generation (RAG) is failing and how to fix it?</title>
      <dc:creator>Anannya Roy Chowdhury</dc:creator>
      <pubDate>Tue, 17 Mar 2026 05:41:19 +0000</pubDate>
      <link>https://dev.to/royanannya/is-your-production-rag-giving-up-too-3pi0</link>
      <guid>https://dev.to/royanannya/is-your-production-rag-giving-up-too-3pi0</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegdz58rmxrntau29fp1v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegdz58rmxrntau29fp1v.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why Most RAG Systems Fail in Production — and How Developers Can Fix It&lt;/p&gt;

&lt;p&gt;Over the past 2-3 years, many developers have built Retrieval-Augmented Generation (RAG) applications.&lt;/p&gt;

&lt;p&gt;The typical journey looks something like this:&lt;/p&gt;

&lt;p&gt;Step 1 - Connect a Vector Database&lt;br&gt;
Step 2 - Index documents&lt;br&gt;
Step 3 - Send retrieved context to an LLM&lt;br&gt;
Step 4 - Ship a chatbot&lt;/p&gt;

&lt;p&gt;At first, everything works. But once the system reaches real users, the issues start appearing.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The assistant retrieves irrelevant documents&lt;/li&gt;
&lt;li&gt;Answers sometimes hallucinate&lt;/li&gt;
&lt;li&gt;Latency increases as the knowledge base grows&lt;/li&gt;
&lt;li&gt;The system becomes expensive to run&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If this sounds familiar, you’re not alone. Many RAG systems struggle when they move from &lt;strong&gt;prototype to production&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The interesting part is that the problem usually isn’t the language model. It’s the retrieval architecture. Let’s break down what’s actually happening and how you can improve it.&lt;/p&gt;


&lt;h1&gt;
  
  
  The “Simple” RAG Architecture
&lt;/h1&gt;

&lt;p&gt;Most tutorials introduce RAG using a simple pipeline.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User Query
   ↓
Vector Search
   ↓
Top n Documents
   ↓
LLM Prompt
   ↓
Generated Answer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach is great for learning the concept. But production workloads quickly expose some weaknesses.&lt;/p&gt;




&lt;h1&gt;
  
  
  Problem 1: Vector Search Isn’t Always Enough
&lt;/h1&gt;

&lt;p&gt;Vector similarity works well for semantic matching, but real-world queries are messy. A developer might ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“How do I rotate API credentials without downtime?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A pure vector search might retrieve documents related to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API authentication&lt;/li&gt;
&lt;li&gt;security guidelines&lt;/li&gt;
&lt;li&gt;credential policies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of them sound relevant. But none of them may actually contain the exact steps needed to answer the question.&lt;/p&gt;

&lt;p&gt;The result? The LLM tries to generate an answer anyway. This is where &lt;strong&gt;hallucinations&lt;/strong&gt; often begin.&lt;/p&gt;




&lt;h1&gt;
  
  
  Problem 2: Document Chunking Breaks Meaning
&lt;/h1&gt;

&lt;p&gt;Another hidden challenge is &lt;strong&gt;how documents are split before indexing&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Many pipelines use fixed chunk sizes, such as 500 or 1000 tokens. But technical documentation often contains structured sections such as setup instructions, configuration steps, troubleshooting guides, Dos and Don'ts. When these sections are split incorrectly, the retrieval system might return &lt;strong&gt;only part of the information needed&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Chunk A → explains the problem
Chunk B → shows the fix
Chunk C → provides the command
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the model receives only Chunk A, it lacks the context needed to answer correctly.&lt;/p&gt;




&lt;h1&gt;
  
  
  Problem 3: Real Questions Require Multiple Documents
&lt;/h1&gt;

&lt;p&gt;Users often ask questions that require combining information from several sources.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Does this authentication method support multi-region failover?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The answer may exist across multiple documents - authentication documentation, networking architecture guides, availability recommendations&lt;/p&gt;

&lt;p&gt;A simple RAG pipeline retrieves only a few chunks, which may not capture the full picture. This makes it difficult for the LLM to produce a reliable answer.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Production RAG Systems Do Differently
&lt;/h1&gt;

&lt;p&gt;When teams build reliable RAG systems, they usually add additional layers to the retrieval pipeline. Instead of relying on a single search method, they combine multiple techniques.&lt;/p&gt;

&lt;p&gt;A more robust architecture might look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User Query
   ↓
Query Understanding
   ↓
Hybrid Retrieval (Vector + Keyword)
   ↓
Reranking
   ↓
Context Assembly
   ↓
LLM Generation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each layer helps solve a specific problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query understanding&lt;/strong&gt; improves recall by rewriting or expanding queries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hybrid retrieval&lt;/strong&gt; combines semantic similarity with keyword matching.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reranking&lt;/strong&gt; ensures the most relevant documents appear at the top.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Context assembly&lt;/strong&gt; structures the prompt so the LLM receives coherent information.&lt;/p&gt;

&lt;p&gt;Together, these improvements dramatically increase answer reliability.&lt;/p&gt;




&lt;h1&gt;
  
  
  How Developers Can Build Better RAG Systems
&lt;/h1&gt;

&lt;p&gt;Once your RAG system starts handling real workloads, infrastructure becomes just as important as model choice. Production applications must handle - large document collections, high query volumes, strict latency requirements.&lt;/p&gt;

&lt;p&gt;This is where services from &lt;strong&gt;Amazon Web Services&lt;/strong&gt; can simplify the architecture.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Amazon OpenSearch Service&lt;/strong&gt; - Supports hybrid search, allowing you to combine vector similarity with keyword search in the same system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Amazon Bedrock&lt;/strong&gt; - Provides access to foundation models without managing infrastructure, making it easier to experiment with different models.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AWS Lambda&lt;/strong&gt; - Helps orchestrate lightweight retrieval pipelines, enabling query preprocessing and reranking logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Amazon S3&lt;/strong&gt; - Acts as a scalable document store for large knowledge bases and embedding pipelines.&lt;/p&gt;

&lt;p&gt;By combining these services, developers can focus on &lt;strong&gt;improving retrieval logic instead of managing infrastructure&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  Key Takeaways for Developers
&lt;/h1&gt;

&lt;p&gt;If you’re building a RAG application, here are a few practical lessons that can save time:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Don’t rely on vector search alone&lt;/strong&gt; — combine semantic and keyword retrieval.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chunk documents intelligently&lt;/strong&gt; — align chunks with semantic structure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Introduce reranking&lt;/strong&gt; — it often improves answer accuracy significantly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Treat RAG as a search problem&lt;/strong&gt; — not just an LLM problem.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Most importantly, remember that a reliable GenAI system is built across multiple layers: retrieval, augmentation, orchestration, and generation.&lt;/p&gt;




&lt;h1&gt;
  
  
  What We’ll Explore Next
&lt;/h1&gt;

&lt;p&gt;In this post, we looked at &lt;strong&gt;why many RAG systems fail when deployed in production&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In the next article, we’ll walk through a &lt;strong&gt;step-by-step architecture for building a production-grade RAG system on AWS&lt;/strong&gt;, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;hybrid retrieval pipelines&lt;/li&gt;
&lt;li&gt;document reranking strategies&lt;/li&gt;
&lt;li&gt;latency optimization techniques&lt;/li&gt;
&lt;li&gt;cost-efficient GenAI architectures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're building GenAI applications today, understanding these patterns can make the difference between a prototype and a system that developers actually trust.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>systemdesign</category>
      <category>rag</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
