Multi-agent AI orchestration. Real-time WebSocket debate. Spatially rendered field execution.
Cricket captains have 30 seconds.
Thirty seconds to read a wet outfield, a batter on 84 from 51, the exact bowling matchup history, and a dew forecast that will flip the pitch by over 18. One wrong call — a misplaced fielder, a wrong bowler, an off-pace delivery — and a final over thriller becomes a headline.
No captain does this alone. But most decision-support tools give them a dashboard. Captain Cool OS gives them a debate room.
Captain Cool OS is a real-time multi-agent AI orchestration system that simulates how elite cricket analysts reason about in-match decisions under pressure.
It is not a chatbot. It is not a data dashboard.
It is a tactical command room — four specialized AI agents that challenge each other's logic, expose blind spots, detect internal contradictions, and converge on a spatially rendered field execution plan with a broadcast-ready commentary layer on top.
Every agent step streams live. Every disagreement is visible. The system tells you when it is uncertain — and why.
Most AI cricket tools answer the question: "What happened?"
Captain Cool OS answers: "What do we do in the next 6 balls — and what breaks that plan?"
| Conventional Approach | Captain Cool OS |
|---|---|
| Single LLM call → one answer | Four specialized agents debate in sequence |
| Static recommendation | Agents revise under adversarial pressure |
| Confidence score as a number | Confidence Collapse Visualization — turns red during instability |
| Text description of tactics | Spatially rendered SVG field with bowling trajectory arc |
| Soft output | Hard deterministic grounding via Pressure Engine, Dew Calculator, Win Probability |
| One-shot response | Revision loop (up to 3 rounds) before consensus is locked |
The debate is the feature. Disagreement is not a bug — it is the system working correctly.
Multi-Agent Debate Engine Strategist, Devil's Advocate, Reflection Evaluator, and Narrative Layer agents dynamically debate each tactical scenario. Agents can trigger revision loops when contradictions are detected.
Gemini 2.5 Flash Orchestration All reasoning is powered by Gemini 2.5 Flash with structured JSON output schemas enforced via Pydantic v2. No prompt hacking — fully typed contracts between agents.
Deterministic Tool Layer Pressure Engine, Dew Impact Calculator, and Win Probability Engine provide hard quantitative grounding that agents cannot override. Reasoning must be consistent with the numbers.
Real-Time WebSocket Streaming
Every agent step streams live to the frontend as it completes over ws://localhost:8000/ws/debate. Judges see the reasoning unfold — not just the conclusion.
Cinematic Orchestration HUD
Live system state visualization cycles through:
COMPUTING → STRESS TESTING → CONTRADICTION SCAN → CONSENSUS LOCKED
Confidence Collapse Visualization An SVG telemetry graph that turns red when the debate loop detects tactical instability. If the Strategist and Devil's Advocate cannot reach resolution, the graph shows it in real time.
Tactical Field SVG Renderer Top-down F1-telemetry style cricket field that spatially renders the final AI decision — fielder positions, bowling trajectory arc, and impact zone — zero external dependencies.
Hardened Schema Validation
All Pydantic schemas are fully typed. No additionalProperties conflicts with the Gemini Developer API. The output contracts are deterministic.
Tactical Simulation Mode Graceful degradation with 8-second Gemini timeouts. The orchestration never hangs.
┌─────────────────────────────────────────────────────────────────┐
│ Next.js 15 Frontend │
│ ┌──────────────┐ ┌──────────────────┐ ┌──────────────────┐ │
│ │ Match State │ │ Live Debate │ │ Tactical Field │ │
│ │ Config │ │ Timeline │ │ SVG Renderer │ │
│ └──────────────┘ └──────────────────┘ └──────────────────┘ │
│ WebSocket (ws://localhost:8000/ws/debate) │
└─────────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────────┐
│ FastAPI Backend │
│ │
│ ┌────────────────────────────────────────────────────────────┐ │
│ │ MatchOrchestrator │ │
│ │ (Central State Machine — routes between all agents) │ │
│ └────────────────────────────────────────────────────────────┘ │
│ │
│ ┌───────────┐ ┌──────────────┐ ┌──────────────────────────┐ │
│ │ Stats │ │ Strategist │ │ Devil's Advocate │ │
│ │ Analyst │ │ (Plan A) │ │ (Stress Tester) │ │
│ └───────────┘ └──────────────┘ └──────────────────────────┘ │
│ ┌───────────────────────────┐ ┌──────────────────────────┐ │
│ │ Reflection Evaluator │ │ Narrative Layer │ │
│ │ (Contradiction Scan) │ │ (Commentary Engine) │ │
│ └───────────────────────────┘ └──────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Deterministic Tool Layer │ │
│ │ PressureEngine DewImpact WinProbability Matchup │ │
│ └─────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
Stats Analyst → Strategist (v1) → Devil's Advocate → Reflection Evaluator
↑ │
└─────────── Revision Loop (up to 3 rounds) ◄─────────────┘
│
Narrative Layer
│
Final Tactical Consensus
Stats Analyst — Establishes the quantitative ground truth. Matchup history, venue stats, current pressure score, dew severity, and live win probability. Every downstream agent reasons from this baseline.
Strategist — Produces the primary tactical plan. Bowling selection, field placement geometry, delivery sequencing, and risk-weighted reasoning. This is Plan A.
Devil's Advocate — Attacks Plan A. Specifically designed to find the scenario where the Strategist is wrong: wrong batter read, wrong dew assumption, wrong boundary geometry. Forces the system to stress-test before committing.
Reflection Evaluator — Scans for internal contradictions between the Strategist and Devil's Advocate. If the plan cannot survive scrutiny, it triggers a revision loop. If it can, it certifies the consensus.
Narrative Layer — Translates the final tactical consensus into broadcast commentary. Directive, counterfactuals, risk profile, and commentary voice — the human-readable output layer.
The Tactical Field SVG Renderer is not a static diagram. It is a spatially accurate, top-down rendering of the final tactical decision — updated per consensus:
- Fielder positions placed geometrically at their designated zones
- Bowling trajectory arc rendered from crease to impact zone
- Boundary geometry marked for the high-risk regions the Devil's Advocate identified
- Impact zone overlay shows where the plan concentrates defensive pressure
The Confidence Telemetry Graph runs alongside the debate. Each revision loop that the Reflection Evaluator triggers drops the confidence score. If the agents stabilize, it recovers green. If they cannot resolve, it stays red — and the system flags the decision as high-variance.
Three scenarios are pre-loaded, each designed to stress a different dimension of the debate engine:
| Scenario | Setup | What the System Fights Over |
|---|---|---|
| Wankhede Final Over Thriller | SKY vs Bumrah, heavy dew, death overs | Dew-factor causes confidence collapse; field geometry is contested |
| Chepauk Spin Squeeze | Kohli vs spin duo, turning dry track | Spin effectiveness vs. aggressive field; Devil's Advocate targets over-rotation |
| Chinnaswamy Run Chase Collapse | Defending 45 in 4 overs vs Russell, flat track | Boundary geometry stress test; every meter of field placement is argued |
- Select Wankhede Final Over Thriller from the preset panel
- Click FORMULATE TACTICAL PLAY
- Watch the Live HUD transition:
COMPUTING → STRESS TESTING → CONTRADICTION SCAN - The Confidence Telemetry Graph dips red — the Devil's Advocate has attacked the dew-adjusted field plan
- The Reflection Evaluator triggers a revision loop; the Strategist revises under pressure
- Consensus is locked —
CONSENSUS LOCKEDstate activates - The Tactical Field SVG renders spatially: bowling arc, fielder guards, impact zone
- The Tactical Consensus Panel displays: Directive, Counterfactuals, Broadcast Commentary, Risk Profile
Add screenshots after running the system. Suggested captures below.
| Orchestration HUD | Tactical Field Map | Final Consensus Panel |
|---|---|---|
screenshots/hud.png |
screenshots/field.png |
screenshots/consensus.png |
| Layer | Technology |
|---|---|
| Frontend | Next.js 15 (Turbopack), Tailwind CSS |
| Backend | FastAPI, Python 3.11+ |
| AI Reasoning | Google Gemini 2.5 Flash (google-genai) |
| Schema Validation | Pydantic v2 |
| Real-time Streaming | WebSocket (FastAPI native) |
| Field Visualization | Custom SVG (zero dependencies) |
| Env Management | python-dotenv |
captain-cool-os/
├── agents/
│ ├── base.py # BaseAgent with timeout & fallback logic
│ ├── strategist.py # Primary tactician agent
│ ├── devils_advocate.py # Adversarial stress-testing agent
│ ├── reflection.py # Contradiction detection agent
│ ├── stats_analyst.py # Data-driven quantitative analyst
│ └── narrative_layer.py # Broadcast commentary generator
├── orchestrator/
│ └── engine.py # MatchOrchestrator state machine
├── tools/
│ ├── pressure_engine.py # Deterministic pressure scoring
│ ├── dew_calculator.py # Dew severity computation
│ └── win_probability.py # Real-time win probability
├── shared/
│ └── schemas.py # All Pydantic models
├── backend/
│ └── main.py # FastAPI WebSocket server
├── frontend/
│ └── src/app/
│ ├── page.tsx # Main dashboard UI
│ └── components/
│ └── TacticalField.tsx # SVG field renderer
├── traces/ # Saved execution trace JSONs
├── .env # API key configuration
└── README.md
- Python 3.11+
- Node.js 18+
- A valid Google AI Studio API key
git clone https://github.com/YOUR_USERNAME/captain-cool-os.git
cd captain-cool-os# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r backend/requirements.txt
# Configure environment
cp .env.example .env
# Edit .env and add your Gemini API key:
# GEMINI_API_KEY=AIzaSy...cd frontend
npm installTerminal 1 — Backend:
source venv/bin/activate
PYTHONPATH=. uvicorn backend.main:app --reload --port 8000Terminal 2 — Frontend:
cd frontend
npm run dev| Variable | Required | Description |
|---|---|---|
GEMINI_API_KEY |
✅ | Google AI Studio API Key |
PORT |
No | Backend port (default: 8000) |
HOST |
No | Backend host (default: 0.0.0.0) |
ENV |
No | Environment flag (development / production) |
Google Developer Groups — AI Hackathon 2026
A demonstration of production-quality multi-agent AI orchestration using the Gemini Developer API. Built to show that the most interesting AI products are not the ones with the best single model call — they are the ones where agents disagree, revise, and earn their conclusions.
Captain Cool OS — because great captains trust data, instinct, and their AI.