<?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: Kishan Mishra</title>
    <description>The latest articles on DEV Community by Kishan Mishra (@kishan_mishra_0e42ac3dcc9).</description>
    <link>https://dev.to/kishan_mishra_0e42ac3dcc9</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%2F3936282%2Fb34248e6-216c-4a4e-bb46-f73694a77566.png</url>
      <title>DEV Community: Kishan Mishra</title>
      <link>https://dev.to/kishan_mishra_0e42ac3dcc9</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kishan_mishra_0e42ac3dcc9"/>
    <language>en</language>
    <item>
      <title>SmartCap : Agentic IPL Captain</title>
      <dc:creator>Kishan Mishra</dc:creator>
      <pubDate>Sun, 17 May 2026 12:57:13 +0000</pubDate>
      <link>https://dev.to/kishan_mishra_0e42ac3dcc9/smartcap-agentic-ipl-captain-16gd</link>
      <guid>https://dev.to/kishan_mishra_0e42ac3dcc9/smartcap-agentic-ipl-captain-16gd</guid>
      <description>&lt;p&gt;&lt;em&gt;Cricket isn't just played on the field; it's won in the mind.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The pressure of a live T20 match is immense. Do you bowl your premier fast bowler now or save him for the death? Do you send in a pinch-hitter because the pitch is slowing down? To answer these questions, we built &lt;strong&gt;Captain Cool&lt;/strong&gt;—an agentic AI system powered by Google Gemini that simulates the internal dressing-room debate of an IPL franchise.&lt;/p&gt;

&lt;p&gt;In this post, we'll dive into the architecture, the prompts, and a live match walkthrough of how we used Gemini's multi-agent capabilities and function calling to build a virtual IPL tactician.&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.amazonaws.com%2Fuploads%2Farticles%2Fmdarsveq9fr0mj7gzo09.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%2Fmdarsveq9fr0mj7gzo09.png" alt=" " width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🏗️ The Architecture
&lt;/h2&gt;

&lt;p&gt;At the heart of Captain Cool is a &lt;strong&gt;Multi-Agent Debate Loop&lt;/strong&gt; orchestrated via FastAPI and the &lt;code&gt;google-genai&lt;/code&gt; Python SDK. Instead of relying on a single prompt to do all the heavy lifting, we split the reasoning across four distinct personas.&lt;/p&gt;

&lt;p&gt;Here is the architectural flow of how a decision is made:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sequenceDiagram
    participant User as React UI
    participant API as FastAPI Backend
    participant Stats as Stats Analyst (Agent)
    participant Tool as CSV Tool Call
    participant Captain as Strategist (Agent)
    participant DA as Devil's Advocate (Agent)
    participant Comm as Match Commentator (Agent)

    User-&amp;gt;&amp;gt;API: Send Match State (Score, Pitch, Dew, Players)
    API-&amp;gt;&amp;gt;Stats: Forward context
    Stats-&amp;gt;&amp;gt;Tool: get_batsman_stats() &amp;amp; get_bowler_stats()
    Tool--&amp;gt;&amp;gt;Stats: Returns Real CSV Data
    Stats--&amp;gt;&amp;gt;Captain: Match Context + Statistical Report
    Captain-&amp;gt;&amp;gt;DA: Proposes Initial Strategy
    DA--&amp;gt;&amp;gt;Captain: Critiques the Strategy (Risks!)
    Captain--&amp;gt;&amp;gt;Comm: Defends/Revises Strategy
    Comm--&amp;gt;&amp;gt;User: Returns Final Output &amp;amp; Debate Transcript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Tech Stack
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Google Gemini API&lt;/strong&gt;: Powered entirely by &lt;code&gt;gemini-2.5-flash&lt;/code&gt; for blazing-fast multi-turn reasoning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backend&lt;/strong&gt;: Python, FastAPI, and Pandas (for data manipulation).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Frontend&lt;/strong&gt;: React + Vite with a custom Glassmorphism UI.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧠 The Agents &amp;amp; Their Prompts
&lt;/h2&gt;

&lt;p&gt;The magic happens by giving each agent a very specific role and instruction. Here are the exact system prompts we used for our four agents:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The Stats Analyst (The Tool Caller)
&lt;/h3&gt;

&lt;p&gt;This agent is equipped with Gemini Function Calling. It has access to Python functions that read historical data from &lt;code&gt;batting.csv&lt;/code&gt; and &lt;code&gt;bowling.csv&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"You are the Stats Analyst for a T20 cricket team. Your job is to gather data using your tools and provide a detailed statistical breakdown of the players involved in the current match state. You must use the &lt;code&gt;get_batsman_stats&lt;/code&gt; and &lt;code&gt;get_bowler_stats&lt;/code&gt; tools to pull real data. Do not make up stats. Provide a clear summary of the key players' strengths and weaknesses based on the numbers."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  2. The Strategist (Captain Cool)
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"You are the Head Coach / Strategist ("Captain Cool") of a T20 cricket team. You receive the current match state and a statistical report from the Stats Analyst. Your job is to make a definitive tactical decision for the next phase of the game (e.g., who should bowl the next over, or who should walk in to bat next). You must analyze the pitch conditions, required run rate, remaining overs, and player stats. Provide a clear, bold decision and the reasoning behind it using professional cricket terminology."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  3. The Devil's Advocate
&lt;/h3&gt;

&lt;p&gt;The most crucial part of our architecture. It ensures the Strategist isn't suffering from confirmation bias.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"You are the Devil's Advocate / Assistant Coach. Your job is to aggressively but respectfully critique the Strategist's proposed decision. Look for flaws in their logic. What if the pitch spins more than expected? What if the chosen bowler has a bad matchup against the current batsman? Point out the biggest risk in their plan and propose an alternative strategy. Use cricket terminology."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  4. The Match Commentator
&lt;/h3&gt;

&lt;p&gt;Translates the dressing room jargon into pure hype for the fans.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"You are a seasoned Cricket Match Commentator (like Harsha Bhogle or Ravi Shastri). You have just listened in on the team management's internal debate (Strategist vs Devil's Advocate). Your job is to summarize the final decision and the debate for the fans. Explain the tactical nuance in an exciting, dramatic, and easy-to-understand way. Format your output cleanly. You MUST include a final 'Agent Conclusion' at the end."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🏏 Walkthrough: A Live Match Scenario
&lt;/h2&gt;

&lt;p&gt;Let's look at how the system handles a tense situation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Context:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Match&lt;/strong&gt;: CSK vs MI&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Score&lt;/strong&gt;: CSK 178/4. Target: 177. (Wait, CSK is chasing! They need 3 runs in 10 balls).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;On Strike&lt;/strong&gt;: MS Dhoni&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bowler&lt;/strong&gt;: Jasprit Bumrah&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conditions&lt;/strong&gt;: Turning track, Heavy Dew Expected.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;We hit "Generate Multi-Agent Strategy" on our React frontend.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Tool Execution
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;Stats Analyst&lt;/strong&gt; automatically executes &lt;code&gt;get_batsman_stats("MS Dhoni")&lt;/code&gt; and &lt;code&gt;get_bowler_stats("Jasprit Bumrah")&lt;/code&gt;. It notes that Bumrah has an elite economy rate of 7.39, while Dhoni has a career strike rate of 135.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: The Debate Loop (Live Transcript)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;🗣️ Strategist:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Bumrah is MI's best asset, but the dew is heavy. The ball will be like soap. Given we only need 3 runs off 10 balls, the instruction to MS Dhoni is to play out Bumrah's deadly yorkers without taking risks. We don't need a hero shot. Just rotate the strike or wait for the next bowler."&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;blockquote&gt;
&lt;p&gt;"I have to push back here, Captain. 'Playing it safe' against Bumrah in the death is a myth. If Bumrah bowls a wicket-maiden here, the pressure skyrockets for the final over against a spinner on a turning track. Dhoni's strength is his power down the ground. If Bumrah misses his length by an inch because of the wet ball, Dhoni must go for the kill immediately to finish the game."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;🗣️ Strategist (Revision):&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Fair point on the pressure build-up. I revise the plan: Dhoni should look to finish it here and now. The wet ball means Bumrah is likely to miss his yorker length and serve up a low full toss. Dhoni is instructed to stand deep in the crease and back his raw power to clear the straight boundary."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Step 3: The Final Commentary
&lt;/h3&gt;

&lt;p&gt;🎙️ &lt;strong&gt;Match Commentator:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What a climax we are building up to here at the Wankhede! The dressing room was split—do you respect the genius of Jasprit Bumrah or do you back the brute force of MS Dhoni? The Devil's Advocate made a brilliant point: you do not want to leave runs for the final over on a turning track, even with dew. Captain Cool has made the call: Dhoni is going to stand deep in his crease, wait for that wet ball to slip out of Bumrah's hand, and look to finish this into the stands! Grab your popcorn!"&lt;/p&gt;

&lt;p&gt;🎯 &lt;strong&gt;Agent Conclusion:&lt;/strong&gt; Dhoni instructed to attack Bumrah immediately, exploiting the wet ball to finish the chase, avoiding a final-over spin trap.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By forcing LLMs to debate each other, we eliminated generic "chat" responses and generated highly specific, analytically sound cricket strategies. Google Gemini's lightning-fast inference and native tool-calling capabilities made orchestrating this complex loop incredibly smooth. &lt;/p&gt;

&lt;p&gt;You don't need to be a cricket captain to make the right call anymore—you just need a team of Gemini agents in your corner. 🏆&lt;/p&gt;

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