<?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: Talib glacier Max</title>
    <description>The latest articles on DEV Community by Talib glacier Max (@talib_glaciermax_925edce).</description>
    <link>https://dev.to/talib_glaciermax_925edce</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3936235%2Fea93039d-9518-465e-992a-a4a69c0c84b6.png</url>
      <title>DEV Community: Talib glacier Max</title>
      <link>https://dev.to/talib_glaciermax_925edce</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/talib_glaciermax_925edce"/>
    <language>en</language>
    <item>
      <title>Captain Cool — How I built a multi-agent IPL strategist with Gemini &amp; ADK in one sitting</title>
      <dc:creator>Talib glacier Max</dc:creator>
      <pubDate>Sun, 17 May 2026 12:36:51 +0000</pubDate>
      <link>https://dev.to/talib_glaciermax_925edce/captain-cool-how-i-built-a-multi-agent-ipl-strategist-with-gemini-adk-in-one-sitting-2onk</link>
      <guid>https://dev.to/talib_glaciermax_925edce/captain-cool-how-i-built-a-multi-agent-ipl-strategist-with-gemini-adk-in-one-sitting-2onk</guid>
      <description>&lt;p&gt;description: "Five Gemini agents argue with each other about who should bowl the next over. Then they tell you who won the argument."&lt;br&gt;
tags: gemini, agents, ai, cricket&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🏏 &lt;em&gt;Cricket is a captain's game. AI is an orchestration game. This is both.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;You're MS Dhoni. Innings 2, over 17.2, MI need 38 off 16 with Suryakumar set on 48 and Tilak Varma at the other end. Dew is heavy. Jadeja has 1 over left. Mustafizur has 1. Pathirana has 2.&lt;/p&gt;

&lt;p&gt;What do you do?&lt;/p&gt;

&lt;p&gt;There is no clean "right answer" — it's matchup math + pitch read + gut feel + risk appetite, all weighted against the next ball. Real captains decide this in 90 seconds. They confer with the bowling coach, the analyst flashes a sheet, the assistant coach pushes back. Then the captain calls it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That's the system I wanted to build.&lt;/strong&gt; Not a chatbot that recites stats. A &lt;em&gt;dressing room&lt;/em&gt; — multiple specialised agents that genuinely debate, with the disagreement rendered transparently, before a final call is committed.&lt;/p&gt;

&lt;p&gt;This was my submission for the &lt;a href="https://apl-rouge.vercel.app/" rel="noopener noreferrer"&gt;Agentic Premier League&lt;/a&gt; by GDG Cloud Pune. Mandatory stack: Google Gemini, ADK, Antigravity, AI Studio. So I leaned in.&lt;/p&gt;


&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;Five Gemini-powered agents, orchestrated by &lt;strong&gt;ADK's &lt;code&gt;SequentialAgent&lt;/code&gt;&lt;/strong&gt;, each writing to shared session state that the next agent reads via prompt template substitution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        ┌───────────────────────────────────────────────────────┐
        │                Captain Cool (SequentialAgent)         │
        └───────────────────────────────────────────────────────┘
   1. Stats Analyst  (Flash) ──── FunctionTools: lookup_batter,
                                                  lookup_bowler,
                                                  lookup_venue,
                                                  matchup_score
   2. Pitch Reader   (Flash) ──── FunctionTool:  lookup_venue
   3. Strategist     (Pro)   ──── FunctionTool:  win_probability   ← proposes
   4. Devil's Adv.   (Pro)   ──── FunctionTool:  win_probability   ← challenges
   5. Strategist     (Pro)   ──── FunctionTool:  win_probability   ← revises / defends
   6. Commentator    (Flash)                                       ← packages for fans
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why &lt;code&gt;SequentialAgent&lt;/code&gt; over a &lt;code&gt;LoopAgent&lt;/code&gt;? Because the &lt;em&gt;roles are sequential and named&lt;/em&gt;. A captain's debate isn't an unbounded loop — it's a structured exchange: stats → conditions → call → challenge → defend → publish. ADK lets me model that exactly.&lt;/p&gt;

&lt;p&gt;Two Strategist invocations sit in the pipeline (&lt;code&gt;StrategistPropose&lt;/code&gt; and &lt;code&gt;StrategistRevise&lt;/code&gt;) because the same role is asked to do two distinct things — write to different &lt;code&gt;output_key&lt;/code&gt;s, with the second reading the dissent before deciding to defend or revise.&lt;/p&gt;




&lt;h2&gt;
  
  
  The agents (with their actual prompts)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Stats Analyst — &lt;code&gt;gemini-2.5-flash&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You are the Stats Analyst on a virtual IPL captain's bench.
Your job: take the raw match state and produce a factual brief.

Required tool usage:
- For each batter at the crease, call `lookup_batter` once.
- For each bowler with overs remaining, call `lookup_bowler` once.
- Call `lookup_venue` for the ground.
- For the bowler types still available, call `matchup_score` against the striker.

Output format (strict, in this order):
**MATCH SITUATION** — one sentence
**BATTERS** — name, handed, role, SRs vs pace / spin / leg-spin
**BOWLING OPTIONS** — type, overs left, phase economy, who they favour
**VENUE &amp;amp; CONDITIONS** — par score, ground size, dew expectation, pitch behavior
**KEY MATCHUPS** — 2-4 bullets of the most decisive matchups

Be terse. This is a brief, not a column.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The strict output format matters — downstream agents read it via &lt;code&gt;{stats_brief}&lt;/code&gt; template substitution, so consistent structure beats verbose prose.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Pitch Reader — &lt;code&gt;gemini-2.5-flash&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Translates pitch / dew / boundary size into actionable "do X, avoid Y" guidance. I want this in voice-of-a-coach, not voice-of-a-model:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"two-paced wicket — stroke-makers will find it hard to time the cut"&lt;br&gt;
"dew is coming in by the 12th over — bowling first will get the harder ball gripping for half the innings"&lt;br&gt;
"60-metre straight boundary — leg-spin into the breeze is asking for trouble"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  3. Strategist (Propose) — &lt;code&gt;gemini-2.5-pro&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The captain. Reads both briefs, calls &lt;code&gt;win_probability&lt;/code&gt;, commits a call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**THE CALL** — one specific sentence (who bowls / who comes in / field setup)
**WHY (cricket talk)** — 3–5 sentences in commentator language
**WIN PROBABILITY** — number from tool call + meaning
**ALTERNATIVE CONSIDERED** — the second-best option ruled out
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Devil's Advocate — &lt;code&gt;gemini-2.5-pro&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;This is the agent that makes the system &lt;em&gt;agentic&lt;/em&gt; — not just a pipeline. Its prompt explicitly says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"You are NOT here to disagree for the sake of disagreement. You are here to surface the &lt;em&gt;best alternative&lt;/em&gt; the Strategist may have under-weighted. If the proposal is genuinely correct, say so plainly and stand it up."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And critically: it calls &lt;code&gt;win_probability&lt;/code&gt; on its &lt;em&gt;counterfactual&lt;/em&gt;, so its dissent comes with a number, not vibes:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"If we bowl Mustafiz at SKY here, WP drops to 0.62. Save him for the 19th when Hardik's at strike; that climbs back to 0.71."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  5. Strategist (Revise) — &lt;code&gt;gemini-2.5-pro&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Reads the proposal and the dissent. Decides: &lt;strong&gt;DEFEND&lt;/strong&gt; or &lt;strong&gt;REVISE&lt;/strong&gt;. Has explicit guidance against caving and against pride:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Don't cave to the dissent just because it sounds smart. Don't cling to your call out of pride. This is the difference between an average captain and a great one."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Outputs a &lt;strong&gt;CONFIDENCE&lt;/strong&gt; number 0-100 and a &lt;strong&gt;WHY-NOT-THE-ALTERNATIVE&lt;/strong&gt; line that directly addresses the dissent.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Match Commentator — &lt;code&gt;gemini-2.5-flash&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The explainability layer required by the rubric. Channels Harsha Bhogle's clarity, Ravi Shastri's punch:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"This is captaincy 101. He's saving Bumrah for the 19th. With the lefty at the crease and dew settling in, it's a no-brainer to bring Jadeja in now."&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The tools (real function calls, not hardcoded JSON)
&lt;/h2&gt;

&lt;p&gt;Five Python functions wrapped as ADK &lt;code&gt;FunctionTool&lt;/code&gt;s:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Used by&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;lookup_batter&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Stats Analyst&lt;/td&gt;
&lt;td&gt;Returns handedness, SR vs pace/spin/leg-spin, role&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;lookup_bowler&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Stats Analyst&lt;/td&gt;
&lt;td&gt;Returns type, phase economies, vs-left/right averages&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;lookup_venue&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Stats Analyst, Pitch Reader&lt;/td&gt;
&lt;td&gt;Returns par score, boundary size, dew factor&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;matchup_score&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Stats Analyst&lt;/td&gt;
&lt;td&gt;Computes batter-vs-bowler-type advantage with handedness adjustment&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;win_probability&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Strategist, Devil's Advocate&lt;/td&gt;
&lt;td&gt;Heuristic WP model: RRR vs CRR, wickets in hand, dew, pitch&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;win_probability&lt;/code&gt; calculator is the &lt;em&gt;real&lt;/em&gt; unlock for the debate. It's a sigmoid-on-rate-gap model — not perfect calibration, but defensible and consistent. Both Strategist and Devil's Advocate call it on &lt;em&gt;different decisions&lt;/em&gt; and compare the deltas. The captain's call now includes a counterfactual: &lt;em&gt;"bowling Pathirana here is WP 0.71; if I'd given Mustafiz the ball instead, it'd drop to 0.62."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Bonus tool: &lt;code&gt;fetch_live_match&lt;/code&gt; (BeautifulSoup over Cricbuzz/ESPN HTML) lets the user paste a live URL and pre-fill the form.&lt;/p&gt;




&lt;h2&gt;
  
  
  The streaming dressing room
&lt;/h2&gt;

&lt;p&gt;One thing I really wanted: &lt;strong&gt;the user should see the disagreement, not just the conclusion.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So the FastAPI endpoint &lt;code&gt;/api/decide/stream&lt;/code&gt; is a Server-Sent-Events stream. Each ADK event yields one of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;tool_call&lt;/code&gt; — small badge appears showing the agent called a function&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;agent_turn&lt;/code&gt; — the agent's final markdown lands as a card&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;final&lt;/code&gt; — structured decision payload renders into the verdict box&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The frontend reads the stream with &lt;code&gt;fetch().body.getReader()&lt;/code&gt; and appends agent cards as they arrive, with a &lt;code&gt;…thinking&lt;/code&gt; ellipsis between turns. It feels like watching a dressing room work in real time.&lt;/p&gt;




&lt;h2&gt;
  
  
  A walkthrough — the Wankhede scenario
&lt;/h2&gt;

&lt;p&gt;The default scenario in the UI:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Wankhede Stadium · 2nd innings · Over 17.2 · MI 148/4 · target 186 · two-paced pitch · heavy dew&lt;/strong&gt;&lt;br&gt;
Suryakumar 48(29) on strike · Tilak Varma 22(18) at the non-striker · Jadeja, Mustafizur, Pathirana, Ashwin all have overs left.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What the agents actually say in this run:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stats Analyst&lt;/strong&gt; flagged the SKY-vs-leg-spin SR of 145 (high), Tilak's left-hand SR vs off-spin (132 — okay), and Pathirana's death economy of 9.1.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pitch Reader&lt;/strong&gt; noted Wankhede is dew-heavy and 64-metre straight — yorker plans favoured, leg-spin into the wind avoided.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strategist (Propose)&lt;/strong&gt; called: &lt;em&gt;"Bowl Mustafiz right now. Angle the ball across SKY, who scores 70% of his off-side runs through cover — a left-armer cramps him. Save Pathirana for the 19th."&lt;/em&gt;  WP: &lt;strong&gt;0.68&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Devil's Advocate&lt;/strong&gt; pushed back: &lt;em&gt;"With dew this heavy, Mustafiz's grip is gone. Even if he beats SKY twice, the four overs he and Pathirana will bowl combined give up 40+. Bowl Jadeja now while the ball still grips, force a strike change, then attack the new batter."&lt;/em&gt; Counterfactual WP for Jadeja-now: &lt;strong&gt;0.71&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strategist (Revise)&lt;/strong&gt; verdict: &lt;strong&gt;REVISE&lt;/strong&gt;. &lt;em&gt;"The dissent's right on dew. Jadeja in — left-arm spin into the lefty Tilak is the mismatch we want."&lt;/em&gt; Confidence: &lt;strong&gt;78&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Commentator&lt;/strong&gt;: &lt;em&gt;"Captaincy 101 from the dressing room. They're going Jadeja before the dew makes him useless — Tilak's the soft target, force a strike turn, then Mustafiz for the 18th when SKY's facing again. Smart cricket, this."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That's the system working.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I'd add next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Memory across overs&lt;/strong&gt; — Gemini context caching so a full innings of debates costs almost nothing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real form pull&lt;/strong&gt; — Cricbuzz player page scraper feeding into &lt;code&gt;lookup_batter&lt;/code&gt; to replace the seed JSON.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vertex AI Agent Engine hosting&lt;/strong&gt; — currently runs locally via &lt;code&gt;python run.py&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multimodal pitch image input&lt;/strong&gt; — upload a photo of the pitch; Gemini Vision reads cracks/wear.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Try it / clone it
&lt;/h2&gt;

&lt;p&gt;GitHub: &lt;code&gt;&amp;lt;your-repo-here&amp;gt;&lt;/code&gt;&lt;br&gt;
AI Studio prompt for the Strategist (Propose): &lt;code&gt;&amp;lt;your-AI-Studio-link&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Built on Google Gemini · ADK · Antigravity · AI Studio · vibed in one sitting.&lt;/p&gt;

&lt;p&gt;🏏 &lt;em&gt;Cricket is a captain's game. Built on Gemini.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>agents</category>
      <category>ai</category>
      <category>gemini</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
