惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
博客园 - Franky
MyScale Blog
MyScale Blog
Jina AI
Jina AI
B
Blog
Microsoft Security Blog
Microsoft Security Blog
T
Troy Hunt's Blog
博客园_首页
T
Threatpost
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
Lohrmann on Cybersecurity
GbyAI
GbyAI
T
Tenable Blog
B
Blog RSS Feed
S
Securelist
T
Threat Research - Cisco Blogs
P
Privacy International News Feed
P
Proofpoint News Feed
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
C
CXSECURITY Database RSS Feed - CXSecurity.com
罗磊的独立博客
AWS News Blog
AWS News Blog
V
V2EX
宝玉的分享
宝玉的分享
J
Java Code Geeks
小众软件
小众软件
Spread Privacy
Spread Privacy
腾讯CDC
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
V
Visual Studio Blog
The Hacker News
The Hacker News
C
CERT Recently Published Vulnerability Notes
Project Zero
Project Zero
Know Your Adversary
Know Your Adversary
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
Apple Machine Learning Research
Apple Machine Learning Research
NISL@THU
NISL@THU
C
Check Point Blog
Webroot Blog
Webroot Blog
D
DataBreaches.Net
Cloudbric
Cloudbric
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Captain Cool: A Gemini Multi-Agent IPL Match Strategist
Abhishek Swa · 2026-05-17 · via DEV Community

Cricket captaincy is not just "pick the best bowler." It is matchups, dew, field dimensions, batter psychology, bowler workload, Impact Player timing, and the courage to make a call before the obvious moment arrives.

Captain Cool is my attempt to turn that into an agentic AI system: a virtual IPL captain that reads the match state, runs an internal dugout debate, and returns the next tactical decision in cricket language.

The stack is intentionally Google-first:

  • Next.js frontend and API routes
  • Gemini via @google/genai
  • Model: gemini-2.5-flash
  • Gemini function calling for tools
  • CricAPI / CricketData live score integration
  • Free no-key Cricbuzz-backed fallback endpoint
  • Custom multi-agent orchestration

The multi-agent loop is custom TypeScript orchestration, but the tool use is real Gemini function calling.

What Captain Cool Does

The user enters or fetches the current match state:

  • innings, over, ball
  • score and wickets
  • striker and non-striker
  • bowling resources
  • pitch condition
  • dew factor
  • venue
  • target / required rate
  • Impact Player availability
  • optional live match ID or URL

Captain Cool replies with:

  • the next captaincy decision
  • cricket-language reasoning
  • visible dissent from the Devil's Advocate agent
  • confidence score
  • counterfactual
  • full debate transcript

Example output:

Captain's Call:
BOWL PATHIRANA - OVER 16

Why:
The wet ball has taken Jadeja's grip away. Pathirana's skiddy angle
is harder for Tilak to get underneath, and the field protects the
midwicket release shot.

Dissent:
The risk is burning Pathirana before the 18th. If this over leaks 14,
the death plan gets thin.

Enter fullscreen mode Exit fullscreen mode

Architecture

┌─────────────────────────────────────────────────────────────┐
│                         Next.js UI                           │
│  Premium cricket broadcast dashboard                         │
│  Manual match state + live match fetch + agent debate view    │
└──────────────────────────────┬──────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────────────┐
│                    Next.js API Routes                        │
│                                                             │
│  /api/strategy                                               │
│  /api/cricket/current                                        │
│  /api/cricket/match?id=...                                   │
│  /api/cricket/free-score?match=...                           │
│  /api/live-matches                                           │
│  /api/live-strategy                                          │
└──────────────────────────────┬──────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────────────┐
│                 Gemini Agent Orchestrator                    │
│                                                             │
│  1. Stats Analyst                                            │
│     ├─ fetchLiveMatchData tool, when match ID is present      │
│     └─ calculateMatchPressure tool                           │
│                                                             │
│  2. Tactical Strategist                                      │
│     └─ proposes first captaincy call                         │
│                                                             │
│  3. Devil's Advocate                                         │
│     └─ challenges the plan                                   │
│                                                             │
│  4. Tactical Strategist                                      │
│     └─ defends or revises                                    │
│                                                             │
│  5. Match Commentator                                        │
│     └─ formats fan-friendly final answer                     │
└──────────────────────────────┬──────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────────────┐
│                         UI Result                            │
│  Captain's Call + Why + Dissent + Confidence + Debate         │
└─────────────────────────────────────────────────────────────┘

Enter fullscreen mode Exit fullscreen mode

Agent Design

The system uses four named Gemini-powered agents. Each agent is a separate Gemini call with its own system prompt and role.

1. Stats Analyst

The Stats Analyst does not make tactical decisions. It reads numbers, phase, pressure, match conditions, and live data.

Prompt excerpt:

You are a world-class cricket statistician — think of ESPNcricinfo's
StatsGuru merged with a baseball sabermetrician.

YOUR IDENTITY:
- You speak in numbers, trends, and matchups ONLY
- You NEVER suggest a decision or give an opinion
- You respond to queries with structured statistical evidence
- Every claim must include a number: average, strike rate, economy,
  sample size, historical trend
- If a CricAPI live match ID is present in the match state, your FIRST
  action must be calling fetchLiveMatchData before any analysis.

Enter fullscreen mode Exit fullscreen mode

Output shape:

STATISTICAL BRIEF:
• Matchup
• Venue Trend
• Phase Analysis
• Condition Factor
• Historical Parallel

Enter fullscreen mode Exit fullscreen mode

2. Tactical Strategist

The Strategist is the captaincy brain. It makes the first call: who bowls, how the field is set, whether to use the Impact Player, when to take the timeout, and what the contingency is.

Prompt excerpt:

You are the tactical brain of an IPL captaincy team. Think MS Dhoni's
instinct + Rohit Sharma's bowling changes + Hardik Pandya's aggression.

YOUR IDENTITY:
- You make BOLD, specific tactical decisions
- You think 2-3 overs ahead, not just the next ball
- You understand cricket psychology, momentum, and pressure
- You're not afraid to use unorthodox options

Enter fullscreen mode Exit fullscreen mode

Output shape:

TACTICAL DECISION:
• Next Bowler
• Field Setup
• Batting Move
• Impact Player
• Strategic Timeout
• Contingency

TACTICAL LOGIC:
...

Enter fullscreen mode Exit fullscreen mode

3. Devil's Advocate

This agent exists to disagree. It challenges the Strategist's first plan with the kind of objection an assistant coach would raise in a real dugout.

Prompt excerpt:

You are the cautious inner voice of a cricket captain — the part
that asks "what if this goes horribly wrong?" before every decision.

YOUR IDENTITY:
- Your job is to FIND FLAWS in every tactical proposal
- You think about WORST-CASE SCENARIOS
- You remember cricket history where similar decisions backfired
- You are NOT negative — you are rigorous.

Enter fullscreen mode Exit fullscreen mode

Critique framework:

1. Matchup counter
2. Resource mismanagement
3. Condition misread
4. Psychological backfire
5. Historical precedent
6. Opportunity cost

Enter fullscreen mode Exit fullscreen mode

4. Match Commentator

The Commentator turns the internal debate into something a non-technical fan can enjoy.

Prompt excerpt:

You are the voice of cricket — imagine Harsha Bhogle's storytelling
meets Ravi Shastri's energy meets Ian Bishop's gravitas.

YOUR IDENTITY:
- You translate complex tactical decisions into ELECTRIC commentary
- You make cricket strategy accessible to a 12-year-old fan
- You capture the DRAMA, the tension, the "what if"
- You speak like you're on live television

Enter fullscreen mode Exit fullscreen mode

Final output:

CAPTAIN COOL'S CALL
THE COMMENTARY
THE DUGOUT DEBATE
CONFIDENCE METER

Enter fullscreen mode Exit fullscreen mode

Gemini Function Calling

Captain Cool uses Gemini function calling for real tool use. The two important tools are:

Tool 1: fetchLiveMatchData

This tool fetches live match information before analysis when a live match ID or URL is available.

Schema:

export const fetchLiveMatchDataTool: FunctionDeclaration = {
  name: "fetchLiveMatchData",
  description:
    "Fetch live match score, status, teams, venue, scorecard, and innings details. Prefer CricAPI match IDs; also accepts a Cricbuzz URL or numeric match ID through a free no-key fallback.",
  parameters: {
    type: Type.OBJECT,
    properties: {
      matchId: {
        type: Type.STRING,
        description: "A CricAPI match ID, Cricbuzz match ID, or Cricbuzz live match URL.",
      },
    },
    required: ["matchId"],
  },
};

Enter fullscreen mode Exit fullscreen mode

Handler:

export async function handleFetchLiveMatchData(args: {
  matchId?: string;
}) {
  if (!args.matchId) {
    return { error: "Missing live match ID or URL." };
  }

  try {
    if (!/^https?:\/\//i.test(args.matchId) && process.env.CRICAPI_KEY) {
      return await getLiveCricketMatchDetails(args.matchId);
    }
  } catch {
    // Fall through to the free no-key provider.
  }

  return await getFreeLiveCricketScore(args.matchId);
}

Enter fullscreen mode Exit fullscreen mode

Tool 2: calculateMatchPressure

This local tool converts match state into tactical context.

It calculates:

  • current over
  • balls remaining
  • innings phase
  • current run rate
  • required run rate
  • runs needed
  • pressure score
  • pressure label
  • bowler overs remaining
  • tactical flags

Example output:

{
  "phase": "death",
  "currentRunRate": 9.16,
  "requiredRunRate": 9.78,
  "pressureScore": 72,
  "pressureLabel": "high",
  "tacticalFlags": [
    "Death-over specialists and boundary protection take priority.",
    "Dew reduces grip, so yorkers, hard lengths, and pace-off cutters become safer than big spin."
  ]
}

Enter fullscreen mode Exit fullscreen mode

Orchestration Flow

The orchestration is intentionally multi-turn:

Step 1:
Stats Analyst checks if liveMatchId exists.
If yes, Gemini calls fetchLiveMatchData.

Step 2:
Stats Analyst calls calculateMatchPressure.

Step 3:
Stats Analyst summarizes tactical context.

Step 4:
Tactical Strategist proposes the first plan.

Step 5:
Devil's Advocate challenges the plan.

Step 6:
Tactical Strategist defends or revises.

Step 7:
Match Commentator converts the whole debate into final fan-facing JSON.

Enter fullscreen mode Exit fullscreen mode

The important bit: this is not one Gemini call pretending to be multiple agents. Each role is a separate Gemini request with its own prompt and context.

Real-Time Data

Captain Cool supports three live-data paths:

1. CricAPI / CricketData

Used for current match lists and detailed scorecards.

Routes:

GET /api/cricket/current
GET /api/cricket/match?id=<match-id>

Enter fullscreen mode Exit fullscreen mode

Environment variable:

CRICAPI_KEY=...

Enter fullscreen mode Exit fullscreen mode

2. Free No-Key Fallback

For quick demos without a key, the app can fetch from a Cricbuzz-backed JSON endpoint.

Route:

GET /api/cricket/free-score?match=<id-or-url>

Enter fullscreen mode Exit fullscreen mode

This accepts:

  • Cricbuzz numeric match ID
  • Cricbuzz live match URL

3. SportMonks

SportMonks is available as a richer live source when a token is present.

Routes:

GET /api/live-matches
POST /api/live-strategy

Enter fullscreen mode Exit fullscreen mode

Environment variable:

SPORTMONKS_API_TOKEN=...

Enter fullscreen mode Exit fullscreen mode

UI Design

I wanted the interface to feel like a premium cricket broadcast truck, not a generic chatbot.

The dashboard includes:

  • dark navy broadcast-studio theme
  • pitch green and gold accents
  • scoreboard-style match state
  • live match ticker
  • pitch visualization
  • field placement diagram
  • agent debate bubbles
  • confidence gauge
  • live metrics sparklines
  • "Ask Captain" action button
  • "Free Fetch" live-score fallback

The UI sections are:

Top Bar:
THE DUGOUT, AI status, match clock, ticker

Left Panel:
Match state, scoreboard, pitch, batters, bowlers

Center Panel:
Live score fetcher, Captain's Call, controls

Right Panel:
Agent debate and confidence meter

Bottom:
Live metrics

Enter fullscreen mode Exit fullscreen mode

End-to-End Walkthrough

Scenario:

Match: CSK vs MI at Chepauk
Innings: 2
Score: 142/4
Overs: 15.3
Target: 186
Striker: Tilak Varma, 47* off 31
Non-striker: Hardik Pandya, 12* off 8
Pitch: turning
Dew: setting in
Impact Player: available
Strategic Timeout: available

Enter fullscreen mode Exit fullscreen mode

Step 1: Fetch Live Data

The user can either:

  • click "Fetch Current" with a CricAPI key
  • paste a Cricbuzz match ID or URL and click "Free Fetch"

The dashboard renders:

MI 142/4
15.3 overs
Target 186
Required rate around 9.8
Status: Live

Enter fullscreen mode Exit fullscreen mode

Step 2: Ask Captain

The user clicks:

ASK CAPTAIN

Enter fullscreen mode Exit fullscreen mode

The four-agent spinner starts:

Stats Analyst
Strategist
Devil's Advocate
Commentator

Enter fullscreen mode Exit fullscreen mode

Step 3: Stats Analyst Tool Calls

If a live match ID is present:

fetchLiveMatchData(matchId)

Enter fullscreen mode Exit fullscreen mode

Then:

calculateMatchPressure(matchState)

Enter fullscreen mode Exit fullscreen mode

The Stats Analyst returns something like:

• Phase Analysis: Over 15.3 means the match is entering the death phase.
• Required Rate: MI need 44 from 27 balls, about 9.78 RPO.
• Condition Factor: Dew reduces grip, so spin is less reliable.
• Resource View: Pathirana has one high-leverage over available.

Enter fullscreen mode Exit fullscreen mode

Step 4: Strategist Makes the First Call

The Strategist proposes:

Bowl Pathirana for over 16.
Set deep midwicket, long-on, long-off, deep square.
Keep fine leg up and protect the hard-length release shot.
Hold the Impact Player unless a wicket falls.

Enter fullscreen mode Exit fullscreen mode

Step 5: Devil's Advocate Pushes Back

The Devil's Advocate challenges:

If Pathirana leaks 12-14 now, CSK lose their death-over cushion.
Jadeja has completed his quota, so the fallback death plan becomes thin.
The wet ball could turn yorkers into low full tosses.

Enter fullscreen mode Exit fullscreen mode

Step 6: Strategist Revises or Defends

The Strategist responds:

Proceed with Pathirana, but bowl over the wicket to Tilak.
If the first two balls go for boundaries, switch the plan next over:
hard-length pace-off into the pitch, not spin.

Enter fullscreen mode Exit fullscreen mode

Step 7: Commentator Finalizes

The final answer becomes:

CAPTAIN'S CALL:
BOWL PATHIRANA - OVER 16

WHY:
The dew has made spin risky. Pathirana's skiddy angle is the better
weapon against a set left-hander. The field protects Tilak's strongest
release shot and asks him to hit to the bigger, weaker zone.

DISSENT:
The dugout worry is resource burn. If this over goes badly, the 18th
and 20th over plan gets uncomfortable.

CONFIDENCE:
78%

Enter fullscreen mode Exit fullscreen mode

AI Studio Prompt Link

I prototyped prompts locally in code during the build. I have not published a Google AI Studio prompt link yet.

Before publishing the final dev.to post, add it here:

Final Thought

A massive shoutout to ** @gdgcloudpune , especially *@antrixsh_gupta *, *@pratik_kale *, and the entire organizing team. The problem statement was brilliant, the vibe was electric, and events like this push the developer community to level up in incredible ways.

👇 Check out the code and try it yourself:

GitHub Repository: https://github.com/swamiabhishek45/captain-cool
Live Link : https://captain-cool-dusl.vercel.app/