Welcome to Captain Cool, a robust, multi-agent AI orchestration pipeline designed to simulate the elite decision-making process of legendary IPL T20 cricket captains. Powered by the Gemini 2.5 Flash model and the official Google GenAI SDK, this tool acts as a comprehensive match strategist for the IPL 2026 season.
Captain Cool utilizes a three-agent architecture to evaluate real-time IPL match situations, fetch relevant statistics, propose tactical moves, aggressively challenge them, and make a finalized "Captain Cool" decision.
- Stats Analyst 📊: Consumes the match state and leverages tool calling (
fetch_live_match_data,fetch_historical_stats) to fetch precise numbers, matchups, pitch conditions, and historical data. - Strategist (Initial Proposal) 🧠: Acting as "Captain Cool," this agent reviews the Analyst's report and the current match state to formulate a single, actionable tactical plan using authentic cricket terminology.
- Devil's Advocate 👿: A highly critical assistant coach who aggressively challenges the Strategist's proposal. This agent looks for counter-matchups, momentum risks, and flaws in the plan.
- Strategist (Final Decision) 🏆: The Captain's final word. After absorbing the Devil's Advocate's critique, the Strategist either pivots or sticks to the original plan, explaining the cricket logic behind the decision.
- Interactive CLI: A beautiful command-line interface powered by
rich, prompting users for real-time match details (Innings, Required Run Rate, Pitch Conditions, Bowlers Remaining, etc.). - Tool Calling: The Stats Analyst automatically calls mock Python functions to fetch live data and historical player statistics.
- Resiliency: Incorporates the
tenacitylibrary for exponential backoff retries, ensuring stability against API rate limits. - Authentic Tone: The prompt engineering ensures agents speak in true cricket jargon without generic AI terminology.
- Clone the Repository: Ensure you have the
captain_cooldirectory. - Install Dependencies:
(Requires
pip install -r requirements.txt
google-genai,rich,tenacity,python-dotenv) - Environment Variables: Create a
.envfile in the root directory and add your Gemini API Key:GEMINI_API_KEY=your_api_key_here
Run the main script to start the interactive CLI:
python main.pyYou will be prompted to enter match details (or press Enter to use defaults). The pipeline will then kick off, and you'll see the multi-turn debate unfold in your terminal with colored panels.
To run a programmatic test without user input:
python test_run.pymain.py: The entry point for the interactive CLI application.orchestrator.py: Contains the multi-agent pipeline logic, handling the turn-by-turn conversation and API calls.agents.py: Holds the system prompts defining the persona of each agent.tools.py: Contains the tool functions (fetch_historical_stats,fetch_live_match_data) used by the Stats Analyst.test_run.py: A script for running programmatic tests of the pipeline.
- Google GenAI SDK (
google-genai) - Gemini 2.5 Flash
- Python 3.10+
- Rich (for terminal UI)
- Tenacity (for robust API retries)