A minimal multi-agent dispatcher for Pi Coding Agent. The primary Pi agent has no codebase tools — it can only delegate work to specialist sub-agents via a single dispatch_agent tool. Each sub-agent runs as a separate pi process with its own tool set.
| Tool | Version | Install |
|---|---|---|
| Pi Coding Agent | >= 0.55 | npm i -g @mariozechner/pi-coding-agent |
| Bun | >= 1.0 | curl -fsSL https://bun.sh/install | bash |
| just | any | brew install just (macOS) or cargo install just |
You also need a working LLM provider configured for Pi (e.g. OpenRouter API key in your .env).
# Copy or clone the dispatch-lite folder into any project
cp -r dispatch-lite /path/to/your-project/
cd /path/to/your-project/dispatch-lite
# Install dev dependencies (only needed for running tests)
bun installNo runtime node_modules are needed — Pi's built-in jiti runtime resolves all imports at load time.
# From inside the dispatch-lite folder:
just start
# Or from anywhere, point Pi at the extension:
pi -e /path/to/dispatch-lite/dispatch-lite.tsOn startup you'll see:
Dispatch Lite: 3 agents loaded (scout, builder, reviewer)
The dispatcher agent has no file tools — it can only think and delegate. Ask it something and it will route to the right sub-agent.
Three agents are included in agents/:
| Agent | Tools | Purpose |
|---|---|---|
| scout | read, grep, find, ls | Read-only recon — explores the codebase and reports findings |
| builder | read, write, edit, bash, grep, find, ls | Read-write — implements changes, writes code |
| reviewer | read, bash, grep, find, ls | Read-only — reviews code for bugs, security, style |
Create a .md file in dispatch-lite/agents/ with YAML frontmatter:
---
name: my-agent
description: What this agent does (one line)
tools: read,grep,find,ls
---
You are a specialist agent. Your instructions go here.Fields:
name(required) — used to dispatch, case-insensitivedescription— shown in the dispatcher's system prompttools— comma-separated Pi tool names (defaults toread,grep,find,ls)- Everything after
---is the agent's system prompt
Restart Pi and the new agent is automatically available.
You: What's the structure of this project? Give me a high-level overview.
The dispatcher will route this to scout, which reads the directory tree and key files, then reports back.
You: Find all TODO comments in the codebase and fix the most critical ones.
The dispatcher will:
- Dispatch scout to grep for TODOs across the codebase
- Review the results and pick the critical ones
- Dispatch builder to implement the fixes
You: Review dispatch-lite/src/dispatch.ts for bugs and improvements.
The dispatcher sends this to reviewer, which reads the file, checks for issues, and returns a bullet-point report.
You: Add a "tester" agent that runs bun test and reports results.
The dispatcher will:
- Dispatch scout to understand the existing agent structure
- Dispatch builder to create
agents/tester.mdwith the right frontmatter - Optionally dispatch reviewer to sanity-check the new agent definition
You: Is there any dead code in the src/ directory? Remove it if you find any.
The dispatcher chains scout (find unused exports/functions) then builder (delete the dead code), then optionally reviewer (verify nothing broke).
# From inside dispatch-lite/
just test
# Or directly:
bun testTests cover the pure functions (frontmatter parsing, agent scanning, prompt building) — no Pi runtime needed.
dispatch-lite/
agents/
scout.md # Read-only recon agent
builder.md # Read-write implementation agent
reviewer.md # Read-only code review agent
src/
types.ts # Shared interfaces (AgentDef, AgentState, DispatchResult)
parse.ts # Pure: frontmatter parser, agent dir scanner, catalog builder
prompt.ts # Pure: dispatcher system prompt builder
dispatch.ts # Side-effectful: spawn("pi") sub-agent runner
dispatch-lite.ts # Pi extension entry point
parse.test.ts # Unit tests for parse.ts
prompt.test.ts # Unit tests for prompt.ts
package.json # Dev dependencies and scripts
justfile # Task runner recipes
README.md # This file
- Session start — the extension scans
dispatch-lite/agents/for.mdfiles, parses frontmatter, and builds an agent catalog - System prompt override — the dispatcher's system prompt is injected with the full agent catalog (names, descriptions, tools) so it knows who to call
- Tool lockdown —
pi.setActiveTools(["dispatch_agent"])removes all codebase tools from the primary agent, forcing it to delegate - Dispatch — when the dispatcher calls
dispatch_agent({ agent: "scout", task: "..." }), a childpiprocess is spawned with that agent's tools and system prompt - Result — the sub-agent's text output streams back and is returned to the dispatcher, which synthesizes a response for the user