Collaborating Agents System (Coordinator + Subagent Playbook)
Use this skill when operating the collaborating-agents extension so coordinators and subagents follow the same protocol.
What this system provides
The extension gives you:
- Agent mesh + messaging via
agent_message - File reservation locking for write/edit coordination
- Subagent spawning via
subagent
Core tools
1) agent_message (coordination + reservations)
Actions:
status— self identity, focus, peer count, reservationslist— active agentssend— direct message to one peer (to,message, optionalreplyTo, optionalurgent)broadcast— message all peers (message, optionalurgent)feed— recent global message log (limit, default 20, max 400)thread— DM history with one peer (to, optionallimit)reserve— reserve write/edit targets (paths, optionalreason)release— release specificpaths, or all if omitted
Delivery semantics (important):
- Normal messages (
urgent: falseor omitted) are delivered with PifollowUp(queued until the current turn completes). - Urgent messages (
urgent: true) are delivered with Pisteer(interrupt immediately).
Common calls:
agent_message({ action: "status" })
agent_message({ action: "list" })
agent_message({ action: "send", to: "BlueFalcon", message: "Started task X" })
agent_message({ action: "send", to: "BlueFalcon", message: "Need decision now", urgent: true })
agent_message({ action: "broadcast", message: "Wave 2 complete" })
agent_message({ action: "thread", to: "BlueFalcon", limit: 20 })
agent_message({ action: "reserve", paths: ["src/server/"], reason: "auth refactor" })
agent_message({ action: "release", paths: ["src/server/"] })
Notes:
- In the
/agentsoverlay, prefix message text with!!to send urgent. - Use urgent only for blockers/decisions that cannot wait.
2) subagent (spawn workers)
Modes:
- Single:
{ task }or{ type, task } - Parallel:
{ tasks: [{ task, cwd? }, ...] }or{ type, tasks: [...] }
Subagent Types (agent-type design)
Subagents are driven by type configs (TOML files). A type controls:
- system prompt
- optional model override
- optional reasoning level (
low | medium | high | xhigh)
You can use built-in types (from examples/subagents) or override/add your own.
Common built-ins include:
worker— general-purpose implementation (default)scout— fast discovery / codebase explorationdocumenter— docs and writeupsreviewer— review / risk analysis- plus many additional bundled specialists in
examples/subagents/*.toml
Type discovery precedence
Later sources override earlier ones when name matches:
- Bundled defaults:
examples/subagents/*.toml - User overrides:
- Legacy:
~/.pi/agent/subagents/*.toml - Also supported:
~/.pi/subagents/*.toml - Preferred:
~/.pi/agents/*.toml
- Legacy:
- Project overrides (nearest ancestor from current cwd):
- Legacy:
.pi/subagents/*.toml - Preferred:
.pi/agents/*.toml
- Legacy:
So by default, bundled examples/subagents are used. Any matching config in the user/project override directories takes priority.
Default type resolution
When no type is passed:
- use the highest-precedence non-bundled
worker.tomloverride if present - else use the highest-precedence non-bundled
default.tomloverride if present - else use bundled
workerfromexamples/subagents/*.toml - else fallback to bundled
examples/subagents/worker.toml - else use emergency inline worker prompt (rare)
TOML shape
name = "scout"
description = "Exploration specialist"
model = "openai/gpt-4o-mini" # optional
reasoning = "low" # optional
prompt = """...required system prompt..."""
Examples
// Default subagent type
subagent({ task: "Implement auth tags and report back via agent_message" })
// With specific subagent type
subagent({
type: "scout",
task: "Find all TypeScript files in src/"
})
// Parallel subagents
subagent({
tasks: [
{ task: "Implement backend pieces" },
{ task: "Implement frontend pieces" }
]
})
// Parallel with specific type (applies to all tasks)
subagent({
type: "documenter",
tasks: [
{ task: "Document backend API" },
{ task: "Document frontend components" }
]
})
Slash command
Users can also spawn subagents via the /subagent command:
/subagent "Implement user authentication"
/subagent scout "Find all API endpoints"
/subagent documenter "Write README for auth module"
Coordinator workflow (recommended)
- Discover peers:
agent_message({ action: "list" }) - Plan work split
- Spawn workers with
subagent - Track progress using
thread/feed - Coordinate reservations so only one writer owns a target path
- Collect worker completion output (auto-collected by orchestrator)
- Release reservations after merge/finalization
Subagent workflow (required behavior)
Spawned workers use a subagent prompt based on their configured type (defaulting to a built-in prompt if no type is specified). At minimum they should:
- At startup call:
agent_message({ action: "status" })agent_message({ action: "list" })
- Send direct updates to coordinator only when useful:
- startup acknowledgement
- blockers/questions needing input
- Do not send a mandatory final DM summary; coordinator collects final output automatically.
- Avoid broadcast progress unless explicitly requested.
- Read before edit, keep changes scoped, run validation when possible.
Expected final report structure from workers:
## Summary## Files Changed## Validation## Notes
Reservation semantics (important)
- Reservation path ending with
/means directory prefix match.- Example:
src/server/blocks writes/edits under that directory.
- Example:
- Reservation path without trailing
/means exact file match. - Conflicts block
write/editcalls by other agents. - Reads are still allowed.
Best practice:
- Reserve before first edit/write.
- Release as soon as ownership is no longer needed.
- Include a
reasonfor auditability.
Limits and defaults
- Parallel task count max: 8
- Parallel runtime concurrency:
min(taskCount, 4) - One active
subagentrun at a time per orchestrator session - Child recursion guard: blocked when depth >= max depth
- Depth env:
PI_COLLAB_SUBAGENT_DEPTH - Max env:
PI_COLLAB_SUBAGENT_MAX_DEPTH(default 2)
- Depth env:
- Spawned worker default tools:
read,write,edit,bash,agent_message
Identity and storage
Base storage directory:
- Default:
~/.pi/agent/collaborating-agents - Override via env:
COLLABORATING_AGENTS_DIR
Stored state:
registry/— active agent registrations + reservationsinbox/— per-agent message queue filesmessages.jsonl— append-only global message log
Agent naming:
PI_AGENT_NAMEcan force explicit agent name- otherwise extension generates readable names and resolves collisions
Failure handling
send: fails if target is inactive, self-targeted, or message is emptybroadcast: fails when no active recipients or message is emptythread: requirestoreserve: requires non-emptypathsrelease: ifpathsprovided, must contain valid entries- Subagent spawn may fail on recursion depth guard or process failure; inspect returned launch/result details
Team protocol (concise)
- Prefer direct messages for task traffic
- Use broadcast only for milestone-level announcements
- Use
urgent: truesparingly for time-critical blockers/decisions - Reserve early, release promptly
- Keep worker scope narrow and report with structured output
- Coordinator is responsible for conflict resolution and final synthesis
Converted and distributed by TomeVault — claim your Tome and manage your conversions.