Q: What's the actual Kelly Router spawn protocol and how does it compare to Gas Town's Mayor pattern?¶
Short answer: Kelly's Router is a work router — it decomposes tasks, spawns specialized sub-agents, validates quality gates, and advances pipeline stages. Gas Town's Mayor is a chief-of-staff information filter — its job is to read all agent output and surface only what the human needs to see. They serve completely different functions in the architecture; the similarity in name is misleading.
Kelly Router's Spawn Protocol¶
The Kelly Router follows a precise, documented spawn protocol defined in kelly-handbook-ch7-multi-agent and operationalized in kelly-factory-overview:
The Four Operations¶
The Router exposes exactly four operations via the subagents tool:
| Operation | What it does |
|---|---|
spawn |
Creates a labeled sub-agent with a task description and output directory |
list |
Shows currently running agents |
steer |
Sends additional instructions to a running agent |
kill |
Stops a running agent |
Spawning Pattern¶
When the Router spawns a sub-agent, it provides:
- Label — a human-readable name for the agent (e.g., carson-research-victor)
- Task definition — what to do, what files to produce, what success looks like
- Output directory — where results land, which downstream agents read as input
The key power move is parallel spawning: three research agents can simultaneously cover three competitors in 5 minutes instead of 15 sequentially. The Router spawns them in parallel, then yields until they complete.
Handoff and Gate Validation¶
Each pipeline stage produces named artifacts. The downstream agent checks a gate file (e.g., research-summary.md) before starting work. The Router validates the gate before advancing stages — nothing proceeds until the quality gate file exists and passes validation.
Named Lead Agents¶
The Router doesn't do the work — it routes to named lead agents:
- research-lead (Carson): Runs the cis-pipeline for Stage 2 research
- project-lead (Mary): Owns planning artifacts (PRD, architecture, UX design)
- test-lead: Runs the TEA audit
- design-lead (Sally), build-lead (Amelia), deploy-lead (Phil): Implementation specialists
Each lead may spawn their own parallel sub-agents for their domain.
RALPH Retry Protocol¶
When a sub-agent fails:
1. Retry immediately
2. Same failure twice → escalate immediately (don't waste a third attempt)
3. Three failures → mandatory escalation with a structured diagnostic (project ID, phase, what failed, error description, attempt count, recommended next steps)
Gas Town's Mayor¶
The Mayor, as described in steve-yegge-gas-town, is a fundamentally different role. Yegge calls it "the killer feature" — not observability dashboards, not activity feeds, just less reading.
The Information Overload Problem¶
Gas Town runs 20–30 concurrent agents producing output constantly. Reading all of that is impossible. The Mayor exists to solve the human's attention bottleneck: the human can only process so much information per day, but the agents produce far more.
What the Mayor Actually Does¶
The Mayor is the human's chief of staff — reading all agent babble so the human doesn't have to. It:
- Reads all agent output across the system
- Filters for what actually matters to the human's decisions
- Surfaces decisions, blockers, and escalations — not raw output
- Acts as the single interface between the human and the factory's operations
Yegge explicitly positions this as a different kind of role than an orchestrator. The Mayor isn't routing work or managing pipelines — it's editorial: deciding what the human sees and when.
Refinery vs Router¶
Gas Town has a separate role called Refinery that decomposes vague epics into well-specified Bead sequences for workers. This is closer to Kelly's Router routing function. But the Mayor is purely an information-filtering interface — it's downstream of the work, not upstream of it.
Kelly's Named Lead Agents and Sub-Agents¶
Kelly's agent hierarchy partially mirrors Gas Town's tier structure:
- Router (≈ Mayor, but routing-focused, not filtering-focused) — orchestrates, routes to sub-agents, validates gates, escalates. Never executes work itself.
- Named lead agents (≈ Crew) — research-lead, project-lead, test-lead, etc. Each is a named specialist that may spawn their own sub-agents. Gas Town's Crew members are named, persistent, and addressable by the human. Kelly's named leads are defined in AGENTS.md and serve a similar role, though not as persistently addressable mid-session.
- Ephemeral sub-agents (≈ Polecats) — spawned for specific tasks, run to completion, then die. This concept is fully present in Kelly.
The gap is Partial — Kelly has the structural equivalents (named leads ≈ Crew, ephemeral sub-agents ≈ Polecats). The gap is in the Mayor role specifically: the editorial information filtering for the human, which is not a routing function but an editorial one.
Information and Liveness Are Conflated in Kelly¶
In Gas Town, the Mayor handles information surfacing and the Deacon handles stuck-worker cleanup — two separate structural roles. In Kelly, these functions are conflated in the Router: the Router is both the escalation path (RALPH retries surface to Router) and implicitly responsible for detecting when sub-agents have stalled.
Kelly's liveness detection has two mechanisms:
1. Heartbeat file — agent-managed; agent must actively update it. If the agent crashes, heartbeat stops. Detection depends on something else noticing the absence.
2. Router DONE marker check — the Router spawns sub-agents with an expected completion window. When a sub-agent completes, it writes a DONE marker. The Router detects a stalled sub-agent when the marker is absent past the expected window. This is more structurally enforced than heartbeat alone, but it's still a configurable timeout, not a hook-age patrol like the Deacon.
The Deacon daemon's external hook patrol is more robust than Kelly's timeout-based DONE marker check, but Kelly's approach requires no additional daemon infrastructure.
Summary Comparison¶
| Dimension | Kelly Router | Gas Town Mayor |
|---|---|---|
| Core function | Route work to specialized agents, validate gates, advance pipeline | Read all agent output, surface only what matters to the human |
| Does the work itself? | Never — routes only | No — reads and filters |
| Information role | Produces artifacts, writes logs | Consumes all agent output, editorial filtering |
| Escalation | Structured RALPH diagnostic surfaced to operator | Surface decisions and blockers to human |
| Parallel spawning | Yes — key optimization | Yes — but mediated through Refinery |
| Quality gates | Explicit stage gates (READY/NOT-READY, PASS/FAIL) | Implicit in workflow; Witness watches workers |
| Named lead agents (Crew) | Full — Kelly has research-lead, project-lead, test-lead, etc. | Named, persistent, addressable by human |
| Ephemeral sub-agents (Polecats) | Full — Kelly spawns unnamed ephemeral agents for tasks | Ephemeral workers that run to completion |
| Mayor role (information filtering) | Partial — only the editorial filtering is a partial gap | Chief-of-staff editorial filtering absent |
| Deacon role (liveness/stuck workers) | Partial — DONE marker timeout detection present but less formally enforced than Deacon's hook patrol | External daemon actively patrols hooks |
Related¶
- kelly-handbook-ch7-multi-agent — Router architecture, subagent spawning, RALPH protocol
- kelly-factory-overview — Router role in the 6-stage pipeline, named lead agents, sub-agent patterns
- steve-yegge-gas-town — Mayor as the killer feature, information-filtering chief-of-staff role
- kelly-gas-town-gap-analysis — Full gap analysis with adoption priority for Mayor-equivalent