🏏 Building “Captain Cool” — A Multi-Agent IPL Strategist Powered by Google Gemini

What if an AI system could think like a cricket captain during a live IPL match?

Not just predict outcomes — but actually debate tactics, analyze player matchups, calculate bowling resources, and make pressure decisions the way elite captains do.

That was the idea behind “Captain Cool”, a multi-agent AI system I built for the Agentic Premier League 2026 using the official Gemini SDK, Streamlit, and real-time cricket data.

The project was inspired by the tactical calm and decision-making style of MS Dhoni.

🚀 The Idea

Modern LLM applications often rely on a single AI model handling everything.

But cricket strategy is not a one-dimensional problem.

During a match, multiple perspectives matter simultaneously:

Statistical analysis
Match conditions
Risk management
Psychological pressure
Tactical adaptability

So instead of one AI agent, I designed a multi-agent orchestration system where different AI agents specialize in different responsibilities and debate decisions before arriving at a final tactical recommendation.

🧠 Multi-Agent Architecture

The system consists of four independent Gemini-powered agents:

📊 Stats Analyst Agent

Responsible for:

Match state analysis
Win probability estimation
Batter vs bowler matchups
Resource optimization
Economy rate analysis
🧠 Strategist Agent

The “captain brain” of the system.

This agent proposes tactical decisions such as:

Bowling changes
Field placement ideas
Match-up exploitation
Death-over planning
Impact Player usage
👹 Devil’s Advocate Agent

This was one of the most fun parts to build.

Instead of blindly accepting the strategist’s decision, this agent actively:

Challenges assumptions
Detects tactical risks
Suggests safer alternatives
Simulates counter scenarios

This significantly improved output quality.

🎙️ Match Commentator Agent

Transforms the final tactical decision into a broadcast-style explanation inspired by professional cricket commentary.

⚙️ Tech Stack

Built using:

Python
Streamlit
Official Gemini SDK (google-genai)
Google Antigravity
BeautifulSoup
Cricbuzz live scraping
Multi-agent orchestration logic
📡 Live Match Intelligence

The app accepts a live Cricbuzz URL and extracts:

Score
Overs
Wickets
Batters
Bowlers
Playing XI
First innings score
Venue details

This data becomes the shared “world state” for all agents.

📐 Bowling Resource Engine

One challenge in cricket strategy is managing bowling resources properly.

I implemented a workload model using ball-level calculations:

text{Balls Bowled} = (text{Overs} times 6) + text{Balls}

and:

text{Overs Remaining} = 24 – text{Balls Bowled}

This allowed the strategist to intelligently preserve death-over specialists instead of exhausting them too early.

🔥 Gemini Fallback System

One major engineering challenge during development was API quota exhaustion.

To solve this, I built a hot-fallback mechanism:

Primary model → gemini-2.5-flash
Automatic fallback → gemini-flash-latest

If the orchestrator detects:
429 RESOURCE_EXHAUSTED

the system instantly switches models and retries automatically without crashing the application.

This made the system far more resilient during rapid testing.

🏏 Example Tactical Debate
Match Situation

RCB: 222/4
PBKS: 10/1 chasing 223

Strategist Agent

Bowl Chahal in the 18th over. Use spin against the new batter and force the aerial shot.

Devil’s Advocate Agent

Risky call. Chahal’s death-over economy is vulnerable on shorter boundaries. Starc provides safer seam angles.

Final Decision

Hold Starc for the 19th. Attack immediately with spin while the batter is unsettled.

This debate-driven workflow produced noticeably more nuanced decisions than direct prompting.

🧩 Key Learnings

Building this project taught me a lot about:

Multi-agent orchestration
Tool calling with Gemini
Structured prompting
Context passing between agents
Real-time data systems
Reliability engineering for LLM apps
Designing AI systems around disagreement instead of consensus

One of the biggest insights:
AI systems become significantly more reliable when agents are allowed to critique each other.

🏆 Final Thoughts

This project was an incredibly fun exploration into combining:

Sports analytics
Multi-agent systems
Real-time AI orchestration
Tactical simulation

Huge thanks to GDG Cloud Pune for organizing the Agentic Premier League and creating a space to experiment with agentic AI systems.

🔗 GitHub Repository: https://github.com/Prantik-1811/Agentic-Premier-League

Agentic Premier League Repository

Would love feedback from:

AI engineers
Cricket nerds
Multi-agent system builders
Anyone experimenting with Gemini workflows

If you were the captain in the 18th over — spin or pace? 👀🏏