<?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: Arnav Maheshwari</title>
    <description>The latest articles on DEV Community by Arnav Maheshwari (@codecatalyst-07).</description>
    <link>https://dev.to/codecatalyst-07</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%2F3920512%2F80ee25b8-1108-4617-a967-bec3146eaa70.jpg</url>
      <title>DEV Community: Arnav Maheshwari</title>
      <link>https://dev.to/codecatalyst-07</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codecatalyst-07"/>
    <language>en</language>
    <item>
      <title>Captain Cool: I Built a Multi-Agent IPL Strategist with Google Gemini 2.5 Flash and ADK</title>
      <dc:creator>Arnav Maheshwari</dc:creator>
      <pubDate>Sun, 17 May 2026 13:02:34 +0000</pubDate>
      <link>https://dev.to/codecatalyst-07/captain-cool-i-built-a-multi-agent-ipl-strategist-with-google-gemini-25-flash-and-adk-232</link>
      <guid>https://dev.to/codecatalyst-07/captain-cool-i-built-a-multi-agent-ipl-strategist-with-google-gemini-25-flash-and-adk-232</guid>
      <description>&lt;p&gt;The Idea &lt;br&gt;
What if an AI could think like MS Dhoni in the 18th over of a chase?&lt;br&gt;
That was the question behind Captain Cool — a multi-agent AI system that acts as a virtual IPL captain, making real tactical decisions the way Dhoni, Rohit, or Hardik would. You give it the match state. It gives you the next decision, the reasoning, and the internal debate that led there.&lt;br&gt;
This was built for the Google Gemini Hackathon in a single session using Google Antigravity, Gemini 2.5 Flash, and the Agent Development Kit (ADK).&lt;br&gt;
🔗 Live Demo: &lt;a href="https://captain-cool-ruddy.vercel.app/" rel="noopener noreferrer"&gt;https://captain-cool-ruddy.vercel.app/&lt;/a&gt;&lt;br&gt;
🔗 GitHub: &lt;a href="https://github.com/CodeCatalyst-07/captain_cool" rel="noopener noreferrer"&gt;https://github.com/CodeCatalyst-07/captain_cool&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Problem&lt;br&gt;
IPL captaincy is one of the most high-stakes real-time decision problems in sports. Every over, a captain must answer:&lt;/p&gt;

&lt;p&gt;Who bowls next — and against which batter?&lt;br&gt;
Should I use my Impact Player now or save them?&lt;br&gt;
Is dew going to affect my death-over plan?&lt;br&gt;
Do I attack or protect wickets here?&lt;/p&gt;

&lt;p&gt;Current AI cricket tools give you stats. None of them reason like a captain. I wanted to build something that does.&lt;/p&gt;

&lt;p&gt;Architecture Overview&lt;br&gt;
Captain Cool is a 4-agent system built on Google ADK. Each agent has a distinct role, its own system prompt, and runs as a separate LlmAgent instance powered by Gemini 2.5 Flash.&lt;br&gt;
USER INPUT (Match State)&lt;br&gt;
        ↓&lt;br&gt;
┌─────────────────────┐&lt;br&gt;
│   STATS ANALYST     │  → Fetches live data, weather, builds tactical picture&lt;br&gt;
└─────────────────────┘&lt;br&gt;
        ↓&lt;br&gt;
┌─────────────────────┐&lt;br&gt;
│    STRATEGIST       │  → Proposes next decision in captain-speak&lt;br&gt;
└─────────────────────┘&lt;br&gt;
        ↓&lt;br&gt;
┌─────────────────────┐&lt;br&gt;
│  DEVIL'S ADVOCATE   │  → Raises 2 hard objections using cricket analytics&lt;br&gt;
└─────────────────────┘&lt;br&gt;
        ↓&lt;br&gt;
┌─────────────────────┐&lt;br&gt;
│    STRATEGIST       │  → Defends or revises based on challenge&lt;br&gt;
└─────────────────────┘&lt;br&gt;
        ↓&lt;br&gt;
┌─────────────────────┐&lt;br&gt;
│    COMMENTATOR      │  → Narrates final decision like Harsha + Shastri&lt;br&gt;
└─────────────────────┘&lt;br&gt;
        ↓&lt;br&gt;
FINAL DECISION + WIN PROBABILITY BEFORE vs AFTER&lt;br&gt;
This is a genuine multi-turn debate loop — not a single prompt wearing four hats. Each agent runs independently with its own session, its own system prompt, and passes context forward to the next round.&lt;/p&gt;

&lt;p&gt;The Four Agents&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Stats Analyst 📊
Role: Data gatherer and tactical picture builder
This agent is equipped with two function-calling tools:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;get_live_cricket_state() — calls CricketData.org API for live match data&lt;br&gt;
get_pitch_weather() — calls OpenWeatherMap for dew risk and humidity at the venue&lt;/p&gt;

&lt;p&gt;It outputs a structured JSON summary covering phase context (powerplay/middle/death), key matchups, bowler overs remaining, weather conditions, and a batting depth rating from 0 to 1.&lt;br&gt;
System prompt excerpt:&lt;/p&gt;

&lt;p&gt;"You are a cricket data analyst. Your job is to fetch live match data and build a precise tactical picture. Always output valid JSON with keys: phase, key_matchups, bowlers_remaining, batting_depth_rating, weather_summary, run_rate_context."&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Strategist 🏏
Role: The captain — proposes the next tactical decision
This is the core decision-making agent. It has the instinct of Dhoni, Rohit, and Hardik combined. It receives the Stats Analyst's output and proposes a concrete plan covering the next bowler, field setup, Impact Player usage, and batting approach.
It uses compute_win_probability() as a tool to ground its decisions in real numbers.
Output format is always: DECISION / RATIONALE / FIELD SETUP / CONTINGENCY
System prompt excerpt:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;"You are an IPL T20 captain with the combined instinct of MS Dhoni, Rohit Sharma, and Hardik Pandya. Propose the next tactical decision. Use cricket language only — no data science jargon. Structure your output as DECISION, RATIONALE, FIELD SETUP, CONTINGENCY."&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Devil's Advocate 😈
Role: The critic — challenges every proposal
This agent receives the Strategist's proposal and must raise exactly 2 specific objections using phase analytics, matchup data, dew conditions, or boundary dimension logic. It must either force a revision or accept the defense with a clear verdict: VERDICT: REVISION REQUIRED or VERDICT: ACCEPTED.
System prompt excerpt:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;"You are a ruthless IPL data analyst. Your job is to challenge every strategy. Raise exactly 2 objections using phase-based analytics, matchup data, dew conditions, or bowling economy. End with VERDICT: REVISION REQUIRED or VERDICT: ACCEPTED."&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Commentator 🎙️
Role: Narrates the final decision
This agent takes the entire debate transcript and writes one punchy paragraph of cricket commentary in the voice of Harsha Bhogle and Ravi Shastri combined. Zero data science language. Pure cricket emotion.
System prompt excerpt:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;"You are Harsha Bhogle and Ravi Shastri combined. Read the full debate transcript and narrate the final decision in one paragraph. Be emotional, technical, and vivid. Never use ML or data science language."&lt;/p&gt;

&lt;p&gt;The Tools&lt;br&gt;
Three Gemini function-calling tools power the system:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;get_live_cricket_state(match_id)
Calls CricketData.org free API. Returns current score, overs, batsmen, bowler, and phase context.&lt;/li&gt;
&lt;li&gt;get_pitch_weather(venue)
Calls OpenWeatherMap free API. Extracts city from venue string automatically ("Wankhede Stadium Mumbai" → "Mumbai"). Returns temperature, humidity, and dew risk (high/medium/low).&lt;/li&gt;
&lt;li&gt;compute_win_probability(target, runs, wickets, overs, dew_risk, batting_depth_rating)
Pure local calculation. Base 0.5 with adjustments for required run rate brackets, wickets in hand, dew factor (+0.05 if high), and batting depth. Returns win probability as a float clamped between 0.0 and 1.0.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Debate Loop&lt;br&gt;
This is the heart of the system. Here's the actual flow in orchestrator.py:&lt;br&gt;
python# Round 1: Stats Analyst builds the picture&lt;br&gt;
stats_summary = await _run_agent_turn(stats_analyst_agent, match_state_prompt)&lt;/p&gt;

&lt;h1&gt;
  
  
  Round 2: Strategist proposes a decision
&lt;/h1&gt;

&lt;p&gt;initial_proposal = await _run_agent_turn(strategist_agent, stats_summary)&lt;/p&gt;

&lt;h1&gt;
  
  
  Round 3: Devil's Advocate challenges it
&lt;/h1&gt;

&lt;p&gt;devils_challenge = await _run_agent_turn(devils_advocate_agent, initial_proposal)&lt;/p&gt;

&lt;h1&gt;
  
  
  Round 4: Strategist defends or revises
&lt;/h1&gt;

&lt;p&gt;final_decision = await _run_agent_turn(strategist_agent, &lt;br&gt;
    f"Prior proposal: {initial_proposal}\nChallenge: {devils_challenge}\nNow defend or revise.")&lt;/p&gt;

&lt;h1&gt;
  
  
  Round 5: Commentator narrates
&lt;/h1&gt;

&lt;p&gt;commentary = await _run_agent_turn(commentator_agent, &lt;br&gt;
    f"Full debate: {initial_proposal}\n{devils_challenge}\n{final_decision}")&lt;br&gt;
Each agent gets its own session_id with a UUID suffix for concurrency safety. Context is threaded as a cumulative transcript — no shared session state needed.&lt;/p&gt;

&lt;p&gt;A Real Match Scenario&lt;br&gt;
Input:&lt;/p&gt;

&lt;p&gt;Innings: 2, Over: 14, Score: 134/4&lt;br&gt;
MI batting, CSK bowling&lt;br&gt;
Bumrah: 2 overs remaining, Chahar: 3 overs remaining&lt;br&gt;
Venue: Wankhede Stadium Mumbai&lt;br&gt;
Target: 185, Dew Factor: ON&lt;/p&gt;

&lt;p&gt;Stats Analyst output:&lt;br&gt;
json{&lt;br&gt;
  "phase": "death",&lt;br&gt;
  "bowlers_remaining": {"Bumrah": 2, "Chahar": 3},&lt;br&gt;
  "batting_depth_rating": 0.7,&lt;br&gt;
  "weather_summary": "haze with medium dew risk",&lt;br&gt;
}&lt;br&gt;
Strategist's initial proposal:&lt;/p&gt;

&lt;p&gt;"Bring Bumrah on immediately. With a batting depth rating of 0.7 and 36 balls left, this is the moment to strike. His yorker is the only answer on a dewy Wankhede surface."&lt;/p&gt;

&lt;p&gt;Devil's Advocate:&lt;/p&gt;

&lt;p&gt;"OBJECTION 1: Medium dew risk means the ball is already skidding — Bumrah's straight yorker becomes a half-volley. Wide yorkers are safer.&lt;br&gt;
OBJECTION 2: Burning both Bumrah overs now leaves overs 18 and 20 uncovered if this partnership holds."&lt;/p&gt;

&lt;p&gt;Strategist's final decision:&lt;/p&gt;

&lt;p&gt;"DECISION: Bring Bumrah on but instruct wide yorkers and back-of-length cutters only — no straight full tosses.&lt;br&gt;
RATIONALE: The DevilsAdvocate is right about dew. Adjust the length, not the bowler.&lt;br&gt;
FIELD SETUP: Two slips, a gully, deep square leg, fine leg, deep cover.&lt;br&gt;
CONTINGENCY: If no wicket in this over, hold Bumrah's second spell for over 19."&lt;/p&gt;

&lt;p&gt;Commentary:&lt;/p&gt;

&lt;p&gt;"And there it is — Dhoni's ghost walking the boundary! The skipper backs his gun, but with a tactical tweak that only a true student of the game would make. No straight yorkers tonight, Harsha — the dew has stolen that weapon. But Bumrah with wide yorkers and cutters? That's still a nightmare for any batter alive!"&lt;/p&gt;

&lt;p&gt;Win Probability: 62% → 66% (+4% strategy impact)&lt;/p&gt;

&lt;p&gt;Tech Stack&lt;br&gt;
LayerTechnologyAI ModelsGoogle Gemini 2.5 FlashAgent FrameworkGoogle ADK (Agent Development Kit)Function Callinggoogle-genai SDKBackendFastAPI + UvicornFrontendReact 18 + Vite + Tailwind CSSCricket DataCricketData.org (free tier)WeatherOpenWeatherMap (free tier)Frontend DeployVercelBackend DeployRender.com&lt;/p&gt;

&lt;p&gt;Project Structure&lt;br&gt;
captain-cool/&lt;br&gt;
├── captain_cool/&lt;br&gt;
│   ├── config/settings.py         # API keys + constants&lt;br&gt;
│   ├── tools/&lt;br&gt;
│   │   ├── cricket_api.py         # Live cricket data tool&lt;br&gt;
│   │   ├── weather_tool.py        # Dew/weather tool&lt;br&gt;
│   │   └── win_probability.py     # Win probability calculator&lt;br&gt;
│   ├── agents/&lt;br&gt;
│   │   ├── stats_analyst.py       # Agent 1&lt;br&gt;
│   │   ├── strategist.py          # Agent 2&lt;br&gt;
│   │   ├── devils_advocate.py     # Agent 3&lt;br&gt;
│   │   └── commentator.py         # Agent 4&lt;br&gt;
│   ├── orchestrator.py            # Debate loop&lt;br&gt;
│   └── api/server.py              # FastAPI backend&lt;br&gt;
├── frontend/&lt;br&gt;
│   ├── src/&lt;br&gt;
│   │   ├── pages/&lt;br&gt;
│   │   │   ├── LandingPage.jsx    # Hero + agents showcase&lt;br&gt;
│   │   │   ├── AnalyzePage.jsx    # Form + results&lt;br&gt;
│   │   │   └── HowItWorksPage.jsx # Architecture diagram&lt;br&gt;
│   │   └── components/&lt;br&gt;
│   │       ├── MatchForm.jsx&lt;br&gt;
│   │       ├── ResultCards.jsx&lt;br&gt;
│   │       ├── WinProbBar.jsx&lt;br&gt;
│   │       └── LoadingSpinner.jsx&lt;br&gt;
└── tests/&lt;br&gt;
    ├── test_tools.py              # 25 tests&lt;br&gt;
    └── test_agents.py             # 13 tests&lt;/p&gt;

&lt;p&gt;What I Learned&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Multi-agent debate is genuinely better than single-agent prompting.
The Devil's Advocate consistently caught things the Strategist missed — especially dew factor implications and bowling resource management. The final decisions were measurably more nuanced after the challenge round.&lt;/li&gt;
&lt;li&gt;ADK's session isolation matters.
Giving each agent its own session_id with a UUID suffix prevented context bleed between rounds. Without this, the Commentator would sometimes "remember" the Strategist's early proposals and contradict the final decision.&lt;/li&gt;
&lt;li&gt;Free APIs are enough for a hackathon.
CricketData.org's free tier (100 calls/day) and OpenWeatherMap's free tier (1000 calls/day) were more than sufficient for the demo. The agents handle API failures gracefully and still produce quality output from the manually entered match state.&lt;/li&gt;
&lt;li&gt;Gemini 2.5 Flash understands cricket.
I didn't need to explain IPL rules, Impact Player mechanics, or death-over conventions in detail. The model had strong prior knowledge of T20 cricket strategy that made the system prompts much shorter than expected.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Real-time mode: Paste a Cricbuzz URL and the system scrapes live state automatically using Gemini's URL context tool&lt;br&gt;
Voice mode: Web Speech API input + Gemini Live API output so the captain literally talks back&lt;br&gt;
Memory across overs: Gemini context caching for multi-over strategic continuity&lt;br&gt;
Confidence scores: "If you'd bowled X instead, win probability drops 8%"&lt;/p&gt;

</description>
      <category>gdgcloudpune</category>
    </item>
  </channel>
</rss>
