Original: https://codingcat.dev/post/gemini-4-neon-antigravity-swarm-multi-agent-teams
One agent is a loop. A swarm is many loops held together by a protocol. If you have ever watched a single AI coding agent burn 120k tokens bouncing between a parser, an API route, and a broken test suite while hallucinating that everything passed, you already know why single-agent loops hit a wall on real features.
In November 2026, Google shipped that multi-agent protocol as a first-class product inside Google Antigravity: /swarm paired with Gemini 4 Neon as the default planner and coordinator, directing parallel Gemini 4 Hydrogen workers with isolated git worktrees and an independent @verifier. In this deep dive, we break down how Antigravity's /swarm actually works under the hood, let you step through a live interactive simulation right inside this post, and then build the exact same Planner, Fan-Out, and Checker Loop in TypeScript with @google/genai and Python with Google ADK.
1. The Mental Model: How Antigravity /swarm Works
When you type /swarm <task> in the Antigravity App or agy CLI, your active conversation stops editing files and becomes the Coordinator. Instead of cramming an entire repo into one giant context window, the swarm splits work into four distinct roles coordinated over an append-only Shared Message Board:
- **Coordinator (Gemini 4 Neon, thinking: high): **Never edits code directly. Splits the goal into non-colliding file lanes, posts public briefs on the board, sleeps (0 tokens) while workers run, and returns one verified summary at the end.
- **Workers (Gemini 4 Hydrogen, low or medium): **Each worker starts in a clean context window and, when edits could overlap, its own isolated
git worktree. Workers only see their brief and their lane, post questions or diffs, and sleep at 0 tokens once they post[done]. - **Verifier (1 per 2 to 4 workers, separate model): **Reads actual git diffs and reruns tests on a different model (such as Gemini 4 Carbon or Neon high). Never trusts a worker's self-reported
[done]. Rejects failing claims directly back to the author so only that lane reruns. - **Monitor (@monitor watchdog): **Stays completely silent (0 tokens) while the swarm is healthy. Speaks only if every member goes quiet or deadlocks.
2. Interactive Walkthrough: Step Through a Live /swarm Run
Press Play or step forward below to watch a real CodingCat.dev Astro feature run through /swarm. Click any agent card or Shared Message Board entry to inspect its git worktree, thinking level, diff payload, and live token cost.
{ "_key": "swarm_sim_745ccd357d", "_type": "swarmSimulator", "ajNote": "Click any agent card or Shared Message Board row to inspect its git worktree, thinking level, and cumulative USD cost.", "command": "/swarm Add a typed /api/bookmarks endpoint with Astro parser, Zod validation, and integration tests", "subtitle": "Watch Gemini 4 Neon plan 3 isolated lanes, fan out to Hydrogen workers in git worktrees, catch a buggy test assertion via @verifier, and ship a verified merge.", "title": "Interactive Antigravity /swarm Simulator" } 3. Picking the Right Gemini 4 Model for Each Seat
The cheapest swarm is the one where every seat runs the smallest model that meets your quality bar. Per token, Neon costs double Hydrogen, yet Google reports 32% lower cost per finished task than Carbon at high thinking because Neon plans cleanly and avoids wasted retries.
| Model | Swarm Seat | Default Thinking | API Price (In / Out per 1M) | Why It Fits |
|---|---|---|---|---|
| Gemini 4 Neon | Coordinator / Planner / Merger | high | $3.00 / $15.00 ($0.15 cached) | Reads fewer files twice, lowest fabrication rate, handles long tool-heavy plans. |
| Gemini 4 Hydrogen | Parallel Workers | low or medium | $1.50 / $7.50 | Half Neon's per-token cost; ideal for narrow scoped edits, parsers, and test suites. |
| Gemini 4 Carbon | Verifier / Hardest Architecture Step | high or medium | $4.00 / $20.00 (post-Nov 30) | Separate model tier for independent verification or brutal long-horizon debugging. |
**AJ Pro-Tip on Thinking Tokens: **Thinking tokens are billed as output tokens. In published benchmarks, Neon at
highcan spend 80% to 90% of its output bill on thinking tokens. Leave the Coordinator and Verifier onhigh, drop simple workers tolow, and never passtemperature,top_p, ortop_kto Neon (in-range values are ignored and out-of-range values return a 400 error).
4. Antigravity /swarm vs. Building Your Own Swarm
Use Antigravity's built-in /swarm when the work lives in your codebase and you want to steer live. Drop down to the Gemini API or Google ADK when the swarm runs headless inside your own product or on a schedule.
| Dimension | Antigravity /swarm (App & agy CLI) | DIY Gemini API (@google/genai) / Google ADK |
|---|---|---|
| Best For | Codebase features, refactors, live human-in-the-loop review | Headless product pipelines, scheduled jobs, custom SaaS backends |
| Orchestration | Built-in Coordinator, Shared Board, git worktrees, @monitor | You control Planner JSON, concurrency semaphore, and Checker loop |
| Observability | Swarm UI side pane, Board / Members / Graph, Alt+S in CLI | Custom logs, adk web event viewer, Cloud Observability |
| Cost Control | Google AI Pro / Ultra subscription quotas | Exact per-run USD budget cap in shared state + 95% prefix caching |
5. Build the Same Swarm in TypeScript (@google/genai)
Every production swarm reduces to three clean patterns: a typed Planner, an async Fan-Out / Fan-In worker pool with a concurrency cap, and a bounded Checker Loop. Here is the complete TypeScript implementation using the official @google/genai SDK.
// src/swarm/planner-and-fanout.ts import { GoogleGenAI, Type } from "@google/genai"; const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY! }); interface SwarmTask { id: string; brief: string; inputs: string[]; outputShape: string; thinkingLevel: "low" | "medium"; } interface Verdict { ok: boolean; problems: string[]; redoTaskIds: string[]; askHuman: boolean; } export async function planTasks(goal: string): Promise<SwarmTask[]> { const res = await ai.models.generateContent({ model: "gemini-4-neon", contents: `You lead a team of fast worker agents. Split this goal into 3 to 6 independent, non-colliding tasks. Goal: ${goal}`, config: { thinkingConfig: { thinkingLevel: "high" }, responseMimeType: "application/json", responseSchema: { type: Type.ARRAY, items: { type: Type.OBJECT, properties: { id: { type: Type.STRING }, brief: { type: Type.STRING }, inputs: { type: Type.ARRAY, items: { type: Type.STRING } }, outputShape: { type: Type.STRING }, thinkingLevel: { type: Type.STRING }, }, required: ["id", "brief", "inputs", "outputShape", "thinkingLevel"], }, }, }, }); return JSON.parse(res.text ?? "[]") as SwarmTask[]; } async function runWorker(task: SwarmTask): Promise<[string, string]> { const res = await ai.models.generateContent({ model: "gemini-4-hydrogen", contents: `Do ONLY this scoped task. Task: ${task.brief} Inputs: ${JSON.stringify(task.inputs)} Return only: ${task.outputShape}`, config: { thinkingConfig: { thinkingLevel: task.thinkingLevel }, }, }); return [task.id, res.text ?? ""]; } export async function runCheckedSwarm(goal: string, maxRounds = 2): Promise<string> { const tasks = await planTasks(goal); const results = new Map<string, string>( await Promise.all(tasks.map((task) => runWorker(task))) ); for (let round = 0; round < maxRounds; round++) { const merged = await ai.models.generateContent({ model: "gemini-4-neon", contents: `Goal: ${goal} Merge these worker results into one verified answer: ${JSON.stringify(Object.fromEntries(results), null, 2)}`, config: { thinkingConfig: { thinkingLevel: "high" } }, }); const check = await ai.models.generateContent({ model: "gemini-4-neon", contents: `Goal: ${goal} Answer: ${merged.text} Check strictly against the goal. Flag anything missing, fabricated, or risky.`, config: { thinkingConfig: { thinkingLevel: "high" }, responseMimeType: "application/json", responseSchema: { type: Type.OBJECT, properties: { ok: { type: Type.BOOLEAN }, problems: { type: Type.ARRAY, items: { type: Type.STRING } }, redoTaskIds: { type: Type.ARRAY, items: { type: Type.STRING } }, askHuman: { type: Type.BOOLEAN }, }, required: ["ok", "problems", "redoTaskIds", "askHuman"], }, }, }); const verdict = JSON.parse(check.text ?? "{}") as Verdict; if (verdict.ok) return merged.text ?? ""; if (verdict.askHuman) { return `NEEDS HUMAN REVIEW: ${verdict.problems.join("; ")}`; } // Targeted retry: only rerun failed task IDs instead of the entire swarm const toRedo = tasks.filter((t) => verdict.redoTaskIds.includes(t.id)); const retried = await Promise.all(toRedo.map((t) => runWorker(t))); for (const [id, text] of retried) { results.set(id, text); } } return `NEEDS HUMAN REVIEW after ${maxRounds} checker rounds.`; } 6. The Same Swarm in Python with Google ADK
If you would rather not hand-roll async orchestration and session state, Google's open-source Agent Development Kit (ADK) gives you ParallelAgent, SequentialAgent, and LoopAgent out of the box, plus adk web to inspect every agent event in your browser.
# swarm_adk.py from google.adk.agents import LlmAgent, ParallelAgent, SequentialAgent def make_worker(name: str, focus: str) -> LlmAgent: return LlmAgent( name=name, model="gemini-4-hydrogen", instruction=( f"Research only {focus} for the requested goal. " "Return 5 concise bullet points with verified sources." ), output_key=name, # Saved directly into shared session state ) team = ParallelAgent( name="worker_team", sub_agents=[ make_worker("pricing", "pricing"), make_worker("features", "features"), make_worker("reviews", "developer reviews"), ], ) merger = LlmAgent( name="neon_merger", model="gemini-4-neon", instruction=( "Merge {pricing}, {features}, and {reviews} into one crisp brief. " "Explicitly flag any claim that lacks a source." ), ) root_agent = SequentialAgent(name="neon_swarm", sub_agents=[team, merger]) 7. What One Production Swarm Run Actually Costs
Swarm pricing is simple arithmetic once you count tokens per seat. Putting Neon on the seats that plan and verify while Hydrogen handles high-volume worker calls keeps a full 8-worker checked run under 50 cents before prompt caching.
| Seat | Model | Input Tokens | Output + Thinking Tokens | Est. Cost |
|---|---|---|---|---|
| Planner | Gemini 4 Neon | 8,000 | 4,000 | $0.084 |
| 8 Parallel Workers | Gemini 4 Hydrogen | 8 x 6,000 | 8 x 1,500 | $0.162 |
| Merger | Gemini 4 Neon | 20,000 | 5,000 | $0.135 |
| Verifier / Checker | Gemini 4 Neon | 15,000 | 3,000 | $0.090 |
| Total (1 Checked Run) | Mixed Fleet | 91,000 | 24,000 | $0.471 |
8. Verdict: Purrfect or Pass?
**Purrfect **for any task that cleanly splits into independent lanes: multi-file feature builds, test coverage sweeps, migration codemods, and parallel research. **Pass **when step 3 strictly depends on step 2's output (that is a sequential pipeline, not a swarm) or when a single 2-file edit takes 15 seconds in one agent loop. Put hard caps on task counts, retry rounds, and per-run dollar budgets in code, and never skip the independent @verifier.
**Sources & Further Reading: **Google's November 2026 Introducing Gemini 4 Neon launch announcement, Antigravity /swarm documentation, Google Agent Development Kit (github.com/google/adk-python), and @zodchiii's practitioner working note on Gemini 4 Neon AI Agent Teams.