What happens when you combine live cricket scraping, a four-agent debate loop, and Google Gemini's function calling capabilities? You get "Captain Cool" — a multi-agent IPL match strategist that doesn't just predict outcomes but actually thinks through bowling changes, field placements, and timeout triggers the way elite captains do. Built for the Agentic Premier League (APL) 2026 hackathon by developer Prantik Chandra, this system represents a fascinating experiment in agentic AI orchestration applied to sports strategy.

The Vision: Bottling Dhoni's Tactical Mind

The core idea behind Captain Cool was ambitious: create an AI that could replicate the calm, calculated decision-making of MS Dhoni — his legendary bowling rotations, his precise field placements, and his ability to read game situations in real time. Chandra set out to solve this for the APL 2026 hackathon, hosted by GDG Cloud Pune and powered by Google Gemini. The result is a fully functional live-scraping system that pulls data from Cricbuzz URLs and processes it through an orchestrated debate between specialized agents before arriving at tactical recommendations.

Architectural Blueprint: Four Agents, One Goal

Captain Cool splits its workload across four distinct, collaborative agents that engage in a structured debate loop. The architecture uses the official google-genai Python SDK with Streamlit as the frontend and Google Antigravity handling deployment. When a user pastes a live Cricbuzz match URL, a dual-page crawler extracts real-time score data from the commentary page while pulling playing XI lists, venue information, and innings totals from the scorecard page — automatically computing targets where applicable.

Meet the Agent Roster

The Stats Analyst Agent serves as the "numbers geek" of the operation, analyzing pitch conditions, calculating dynamic win probabilities using a custom calculate_win_probability() function, running bowler resource audits via get_player_stats(), and evaluating batter-versus-bowler matchups through get_head_to_head(). The Strategist Agent channels an MS Dhoni persona — described in the project as inspired by "Thala's" bold tactical mindset — proposing primary Captain's Calls like bowling changes or timeout triggers. A Devil's Advocate Agent actively challenges these proposals, stress-testing decisions against variables like dew conditions and suggesting statistically safer alternatives. Finally, a Match Commentator Agent transforms finalized tactical calls into high-energy, Harsha Bhogle-style TV broadcast narration complete with hashtag filtering and narrative formatting.

Quota Resilience: Hot-Fallback Architecture

One of the most practical engineering solutions in this build is the Multi-Model Hot-Fallback handler built into orchestrator.py. The system targets gemini-2.5-flash by default but includes automatic detection for 429 RESOURCE_EXHAUSTED errors — common with free-tier quota limits. When triggered, all agents instantly switch to gemini-flash-latest (Gemini 1.5 Flash) on the fly, accompanied by a sleek Streamlit toast notification: "🔄 Quota exhausted on 2.5-flash. Switched to 1.5-flash fallback!" This ensures 24/7 seamless execution without crashes — critical for any production-facing hackathon demo.

Advanced Stretch Features That Actually Matter

Beyond the core debate loop, Captain Cool implements four premium stretch features that showcase Gemini's multimodal and speech capabilities. Voice Commands leverage Chrome's native Speech-to-Text engine through Web Speech Recognition, letting users dictate tactical instructions directly to "Captain Dhoni." Audio Commentary uses Web Speech Text-to-Speech to narrate final decisions aloud in the Harsha Bhogle broadcast style. Multimodal Analysis accepts photo uploads of pitch conditions or scorecard screenshots — the Stats Analyst automatically parses these images and integrates visual cues into the debate. The most technically impressive is Simulated Counterfactual Scenarios: a mathematically-backed scenario simulator that compares proposed bowling changes against alternatives and outputs explicit win probability differentials, like "If you had bowled Mitchell Starc instead of Rasikh Salam Dar, expected run rate would rise, dropping team's win probability by 6.8%!"

Bowler Workload Math & Squad Segregation

The system includes a mathematical model for tracking bowler workloads using the formula: Balls Bowled = (Overs × 6) + Remaining Balls, with Overs Remaining calculated as Overs_To_Balls(24 - Balls Bowled). To prevent mixed-team rosters in the analysis, the scraper maps team_bowling to its parsed roster and strictly filters bowlers_used to only include players in their playing XI and bench — opponent players are completely isolated from calculations.

Key Takeaways

  • Four specialized agents working in a debate loop outperform single-LLM approaches for complex tactical reasoning tasks
  • Hot-fallback architecture between Gemini model versions ensures production-grade resilience against quota exhaustion
  • Multimodal inputs (images, voice) combined with real-time web scraping create genuinely interactive AI systems
  • Mathematical models like bowler workload tracking add credibility and analytical depth beyond generic LLM responses

The Bottom Line

Captain Cool demonstrates what's possible when you stop treating LLMs as chatbots and start architecting them as collaborative agent systems with specific roles, real data sources, and built-in debate mechanisms. Currently sitting at 2nd place in APL 2026 with 960 points, this project proves that vibe-coding with Google Antigravity can produce surprisingly sophisticated results — and that the future of AI isn't one model doing everything, but multiple specialized agents working together under a smart orchestrator.