Cursor's Agent Swarm Rebuilt SQLite: How Planner-Executor Separation Cut Costs 8x

Cursor’s latest experiment hands a swarm of AI agents one asset — the 835-page official SQLite manual — and nothing else: no source code, no test suite, no binaries, no internet. The assignment: build a working database engine in Rust from scratch. The new swarm architecture passed every reserved SQL conformance test. More consequential is the economics: combining a frontier model for planning with cheap models for execution cut the bill from $10,565 (all-frontier) to $1,339 — nearly 8× cheaper.

The lesson for developers is not “agents can replace database engineers.” It is that at scale, how you orchestrate agents matters more than which model you pick. Planner-executor separation, hierarchical task trees, shared design documents, and verifiable reference chains are becoming the infrastructure layer of AI coding — and if you run complex projects in Cursor, Windsurf, or Cline, or chain agents for migrations, refactors, and test backfill, this blueprint is directly copyable.

The Core Idea: Split the Task Tree Into Planners and Workers

A single agent owning a large task hits a classic bind: its context must hold the global goal, the current subtask, every historical decision, and code details all at once. Over time it either stares at the tree and misses the forest or vice versa. Cursor’s answer is to split roles along the tree:

  • Planner: decomposes only — never writes implementation. It holds the complete goal and recursively generates well-bounded work units to delegate.

  • Worker: implements only the delegated task, never plans. All of its context goes into one small piece of code.

  • Referee/Reviewer: judges completion and rollback, supplying multiple deliberately offset review perspectives.

  • Conflict Resolver: a neutral third-party agent that owns merge conflicts and cross-planner design contradictions.

The split is fundamentally context isolation: planners never drown in implementation detail; workers never lose focus to the global goal. Cursor’s own claim is that this isolation — not raw parallelism — is the main source of the swarm’s scalability. In engineering terms, the system is a pipeline: goal plus spec → root planner → recursive delegation into sub-planners and work units → worker agents → shared design documents with compilable references → conflict coordination plus stacked review passes → a held-out test suite as judge.

And this is not SQLite-only. Cursor reports running similar structures for browser implementations, math problem solving, GPU kernel optimization, open-source vulnerability hunting, coverage improvement, and training-data generation.

Mechanism 1: Shared Design Documents With Compilable References

The fear in multi-agent collaboration is brain-splitting: two planners implement the same concept in different corners of the codebase, unaware of each other. Text-level merge tools resolve textual conflicts, not semantic ones. Cursor’s approach:

  1. Planners write design decisions into a shared design document.

  2. Any code depending on a decision carries a reference pointing at the corresponding document entry.

  3. The reference is machine-verifiable. When a coordinator merges or amends the design document, the reference chain propagates the resolution to all downstream code.

It is type-checking for architecture decisions. Human teams write ADRs (Architecture Decision Records) by hand and let them rot; here the ADR is a first-class citizen — maintained by agents, enforced by the compiler. A simplified sketch:

// Design-decision reference in code: points at design doc entry B-07
// @design-ref: B-07 "SQL expression evaluation uses the Row struct uniformly"

#[derive(Clone, Debug)]
pub struct Row {
    // ... field definitions
}

pub fn eval_expr(expr: &Expr, row: &Row) -> Value {
    // implementation details
}

In a real implementation the reference lives as a comment plus a static check. The point: make design intent trackable, mergeable, and verifiable — not something agents must remember from conversation history.

Mechanism 2: a Version Control System Built for Agents

Git tolerates a thousand commits per hour. Cursor’s new swarm peaks near 1,000 commits per second, where Git’s coarse locking and merge model simply fail. The old swarm’s Grok 4.5 run produced 68,000 commits in two hours and accumulated over 70,000 merge conflicts — one file was touched by 1,173 different agents and hit 7,771 conflicts. The new swarm ran four hours with fewer than 1,000.

So Cursor wrote its own VCS, and it pushes conflict coordination down into version control itself: commits small enough to expose conflicts; conflicts routed to the neutral resolver agent; bloated files flagged and frozen against new commits until an external agent splits the module. The takeaway for anyone running concurrent agents on one codebase: before sharing Git branches, settle conflict discovery, conflict resolution, and module boundaries — otherwise more agents mean deeper merge hell.

Mechanism 3: Allow Breaking Changes — On Purpose

On human-maintained codebases, agents tiptoe around core code, and core modules slowly fossilize. Cursor’s fix: agents may proactively introduce annotated breaking changes. The flow: an agent decides core code needs restructuring and submits a patch with an explanatory note; the compiler propagates the impact system-wide and related modules fail to build; other agents read the note, understand the cause, and update their own code. Refactoring stops being an expert-only ritual and becomes standard swarm procedure. The preconditions: changes must carry explanations, and failures must propagate.

Mechanism 4: a Held-Out Test Suite as Judge, Not Target

Scoring used SQLite’s sqllogictest — millions of SQL queries verifying that different engines return consistent results for the same queries. Crucially, the agents never knew the suite existed, and the team manually reviewed code and run logs afterward to confirm no gaming. The lesson generalizes: let agents write their own tests and they will write tests they can pass. A fixed, invisible test suite is the only honest measure. A practical setup:

# Keep a portion of test cases hidden from the agents
# Public tests: used for the agent's own iteration
public_tests/

# Held-out tests: run only at final evaluation
held_out_tests/

# Evaluation script
python evaluate.py --engine ./target/minisqlite --tests held_out_tests/

Held-out tests are the simplest defense against agent self-deception.

Model Economics: Expensive Planners, Cheap Workers

Cursor ran four model mixes; all passed, at wildly different costs:

ConfigPlannerWorkerApprox. costResult
All-frontierGPT-5.5GPT-5.5~$10,565Pass
Cost baselineGrok 4.5Grok 4.5MediumPass
Hybrid AOpus 4.8Composer 2.5$1,339100% pass
Hybrid BFable 5Composer 2.5Slightly higherPass
  • Workers consume at least 69% of tokens — usually over 90%.

  • Yet planner tokens, though few, account for roughly two-thirds of the cost.

  • Frontier intelligence is genuinely needed only for task decomposition, design decisions, and key trade-offs.

  • Once the planner compresses uncertainty into explicit instructions, cheap models execute faithfully.

The conclusion is blunt: do not run frontier models through the whole chain. Give high-uncertainty work to strong models and high-certainty work to fast ones.

How to Reuse This in Your Own Project

1. Start from task decomposition

Don’t ask an agent to build a whole module. Have a strong model emit a hierarchical task tree first:

Goal: add OAuth2 login to an existing Django project
├── Subtask 1: add dependencies and configure settings
├── Subtask 2: implement the OAuth provider adapter
├── Subtask 3: implement user binding/creation logic
├── Subtask 4: add login and callback routes
├── Subtask 5: write unit tests
└── Subtask 6: write integration tests

2. Attach acceptance criteria to every leaf

  • Passes the public suite at pytest tests/oauth/.

  • The /auth/callback/ route returns 302 and sets session["user_id"].

  • Introduces no new unhandled exception types.

3. Cheap models execute; strong models review

Workers: Claude Sonnet / GPT-4o-mini class / DeepSeek-V3 for the code. Planners and reviewers: Opus-class / GPT-5.5 / Kimi K3 for decomposition and final review.

4. Keep a held-out set

Hide 20% of test cases and run them only at final evaluation — the antidote to overfitting the visible tests.

5. Never let two agents write the same file

If concurrency is unavoidable, draw module boundaries first — or enjoy the old swarm’s 7,771-conflicts-in-one-file nightmare.

Resources

When a task outgrows any single agent, the combination of “strong model plans, cheap models execute, shared design documents coordinate, held-out tests judge” beats raw model capability on both cost and control. Cursor has drawn the route map — the remaining work is taking it apart inside your own codebase.

Related News