In the high-pressure cooker of T20 cricket, a captain has mere seconds to make decisions that dictate the outcome of a match. Who bowls the death overs? How do you set a field for a rampaging Suryakumar Yadav on a gripping pitch?
For the Agentic Premier League, I set out to solve the captain-strategist problem. Standard AI chatbots are too generic & agreeable to make tough, high-stakes sports decisions. To fix this, I built Captain Cool, a virtual IPL captain powered by the Google Gemini stack.
Instead of a single prompt, Captain Cool uses a Multi-Agent Debate Framework orchestrated via the Google Agent Development Kit (ADK). It actively fetches live weather data, proposes a strategy, aggressively critiques its own plan, and outputs a fan-friendly tactical breakdown.
Here is a deep dive into the architecture, the agentic design, and how to run it yourself.
ποΈ High-Level Design (HLD) & Architecture
To achieve a true "agentic" workflow, the system cannot rely on a single LLM call wearing multiple hats. It requires distinct personas executing a sequential loop.
The application is built on a Python backend wrapping the google-genai SDK and the google-adk. The frontend is a sleek, responsive dashboard built with Streamlit.
The 5-Turn Agentic Loop
Here is the logical flow of our system.
π¬ Low-Level Design (LLD): The Agentic Team & Prompts
To optimize for both speed and deep reasoning, I utilized model routing. The deep-thinking agents (Strategist/Advocate) run on gemini-2.5-pro, while the fast data-gatherers and summarizers (Analyst/Commentator) run on gemini-2.5-flash.
Here are the system prompts engineered for the team:
1. The Stats Analyst (The Tool Caller)
Model: gemini-2.5-flash
Role: To ground the LLM in reality rather than hallucinating conditions.
Prompt:
"You are a precise cricket data analyst. You will receive a JSON of the current match state. Before doing anything else, you MUST execute your provided Python tool call
get_venue_weather(venue)to fetch the live temperature and dew risk for the provided stadium. Append this real-world data to the match context and pass it forward."
2. The Strategist (The Captain)
Model: gemini-2.5-pro
Role: The primary decision-maker.
Prompt:
"You are an elite, proactive IPL Captain (think MS Dhoni or Rohit Sharma). Review the match state and the Analyst's weather report. Propose the exact next tactical decision: who bowls the next over, the field setup, and how to utilize remaining bowlers for the death. Be decisive and explain your cricketing reasoning based on matchups and pitch conditions."
3. The Devil's Advocate (The Skeptic)
Model: gemini-2.5-pro
Role: To force the AI to self-correct and avoid obvious traps.
Prompt:
"You are a ruthless cricket tactician and skeptic. Review the Strategist's proposal. Your ONLY job is to attack this plan. Point out vulnerabilities, batter vs. bowler mismatches, or instances where they ignored the dew factor or pitch conditions. Do not be polite. Highlight the risk of their strategy."
4. The Match Commentator (The Explainer)
Model: gemini-2.5-flash
Role: Fan-facing communication and stretch-goal execution.
Prompt:
"You are a charismatic cricket commentator like Harsha Bhogle. Take the Strategist's final defended decision and explain the internal debate to the fans in exciting, natural cricket language. YOU MUST INCLUDE TWO THINGS AT THE END: 1) A Confidence Score (0-100%) for the decision. 2) A 'Counterfactual' explaining exactly how the win probability would drop if they had taken the safe route instead."
π‘ Architectural Choice: Cost & Latency Optimization
By routing the heavy analytical debate turns to gemini-2.5-pro and the high-speed data fetching and summary turns to gemini-2.5-flash, the architecture maximizes tactical accuracy while minimizing overall token latency and API consumption costs.
βοΈ Real Tool Calling in Action
Instead of hardcoding a JSON payload to fake "live context," the Stats Analyst agent uses Google Gemini's native function calling to execute a real Python script.
When the user inputs "Wankhede Stadium", the Analyst executes a function that pings the free Open-Meteo API, parses the coordinates, and returns the exact live temperature and humidity to determine the dew risk. This proves the system can break out of its training data and interact with the live internet to make decisions.
πΈ End-to-End Walkthrough: The Wankhede Scenario
Let's look at the system in action during a high-stakes scenario.
The Situation: 2nd Innings. 15.6 overs gone. 67 runs needed off 24 balls. Suryakumar Yadav (75 off 34) is on strike. Pitch is slowing down and gripping.
Once we click "Generate Strategy", the ADK routes the inputs through our 5-turn debate.
The Debate:
- The Strategist proposes bowling Rashid Khan in the 17th over, arguing that we need a wicket-taking option immediately on a gripping pitch, saving Bumrah for the absolute death (18 and 20).
- The Devil's Advocate violently objects, calling it a "glaring vulnerability" and a "perilous gamble" because SKY is a master at dissecting wrist-spinners and is fully set.
- The Defense: The Strategist absorbs the critique but defends the move, stating that bowling a medium pacer like Mohit Sharma is just as risky but without the wicket-taking upside. It's a calculated necessity.
Finally, the Commentator agent wraps it up, translating the intense AI reasoning into an engaging broadcast format, complete with a 75% confidence score and a detailed counterfactual.
π Handling Advanced Match Context (Dew & Impact Players)
To satisfy the strict requirements of the problem statement, the system evaluates two high-stakes variables:
- The Dew Factor: Instead of guessing, the Stats Analyst uses live tool-calling to fetch humidity data, allowing the Strategist to know if the ball will turn or slip.
-
Impact Player Availability: The underlying
match_state.jsoncontract accepts an optionalimpact_player_availableboolean flag. When set totrue, the Strategist explicitly evaluates bench options if a quick breakthrough or pinch-hitting acceleration is required in the middle overs.
π― Hitting the Stretch Goals
This architecture was specifically designed to hit the hackathon's advanced requirements:
- Explainability: The Commentator removes ML jargon and outputs pure cricket logic.
- Confidence & Counterfactuals: Hardcoded into the final output agent for deep fan insight.
-
Memory Across Overs: The Streamlit
session_stateappends the final strategy to amatch_historylist. If the user advances the over from 15.6 to 16.0, the context is fed back into the Strategist, ensuring the AI remembers its previous overs!
π» Tech Stack
-
Google Gemini API:
gemini-2.5-pro&gemini-2.5-flash - Google Agent Development Kit (ADK): Orchestrating the multi-agent pipeline.
- Google Antigravity: Google's agentic IDE used for 100% of the vibe-coding and environment setup.
- Streamlit: For the rapid, chat-based dashboard UI.
π Try it Yourself!
Want to see the agents debate your favorite IPL scenarios? The complete codebase is open-source and ready to run locally.
GitHub Repository: https://github.com/mayureshkate/captain-cool-ipl/tree/main
Quick Start Guide:
# 1. Clone the repository
git clone https://github.com/mayureshkate/captain-cool-ipl.git
cd captain-cool-ipl
# 2. Set up the virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Add your Gemini API Key
echo "GEMINI_API_KEY=your_api_key_here" > .env
# 5. Launch the Streamlit App
streamlit run app.py --server.port 3000
Cricket is a captain's game. But with Gemini and ADK, it's an agent's game too.
Built for the Agentic Premier League Hackathon.




Top comments (0)