4.3 KiB
4.3 KiB
name, description
| name | description |
|---|---|
| subagent-registry | Manage named subagent instances with persistent provider pinning and memory. Use when spawning, resuming, listing, or deleting subagents. |
Subagent Registry
Manage named subagent instances. Each agent gets a human-readable name, persistent memory, and pinned provider for KV cache continuity.
Registry File
<project>/.pi/subagents.json:
{
"session": "<session-name>",
"agents": [
{
"name": "<human-readable-name>",
"id": "<agent-uuid>",
"type": "<agent-type>",
"provider": "<provider-config>",
"status": "running|completed|error",
"created": "<ISO-timestamp>"
}
]
}
Rules
- Always ask for a name when spawning a new subagent. Never auto-generate. Ask: "What should I name this subagent?"
- One agent per name. If name exists, ask for a different name.
- Store the agent ID in the registry immediately after spawn.
- Use the same provider when resuming — read from registry.
- Each named agent gets its own memory directory via
memory: projectin agent frontmatter. - No auto-cleanup. Agents persist until explicitly deleted.
- Session-scoped. Registry is per-project directory.
Workflow: Spawn
- User requests a subagent
- Ask for a name if not provided: "What should I name this subagent?"
- Call
Agent({ subagent_type, prompt, run_in_background: true, ... }) - Wait for completion notification with agent ID
- Append to
.pi/subagents.json:{ "name": "<user-given-name>", "id": "<agent-uuid>", "type": "<subagent_type>", "provider": "<provider-config-from-agent-frontmatter>", "status": "running", "created": "<ISO-timestamp>" } - Inform user: "Created subagent '' () using "
Workflow: Resume
- User says "resume " or "tell to..."
- Read
.pi/subagents.json, find agent by name - If not found: "No subagent named ''. Use /subagent-list to see available agents."
- If found:
Agent({ subagent_type, resume: "<agent-id>", prompt: "<new-task>", run_in_background: true }) - Update status in registry to "running"
- Inform user: "Resumed '' () — cache warm"
Workflow: List
Display all agents in a compact table:
Name Type Provider Status Created
---- ---- -------- ------ -------
coder-login coder-pro DeepInfra ✓ done 20:00
coder-nav coder-pro DeepInfra ↻ run 20:05
obsidian-edit obsidian StreamLake ✓ done 19:30
Show: name, type, provider (from config), status, created time.
Workflow: Delete
- User says "delete " or "kill "
- Read registry, find agent
- If running: call
TaskStopor steer to abort - Remove entry from registry
- Inform user: "Deleted '' ()"
Workflow: Delete Session
- User says "delete session " or "clear all subagents for "
- Find all agents where
session == <name> - Abort any running agents
- Remove all matching entries from registry
- Inform user: "Deleted subagents from session ''"
Provider Config Format
Store as string: "only:<provider-slug>"
Examples:
"only:DeepInfra""only:Baidu""only:StreamLake""only:Moonshot AI"
When resuming, parse and reconstruct the provider field:
"only:DeepInfra" → { "only": ["DeepInfra"] }
Memory
Each named agent should have memory: project in its frontmatter. This gives it a persistent memory directory at .pi/agent-memory/<agent-name>/ that survives across resume calls.
Session Name
The session field in the registry should match the pi session name. If no session name is set, use the project directory name.
Example Interaction
User: "Spawn a coder-pro to fix the login module"
LLM: "What should I name this subagent?"
User: "auth-login"
LLM: *spawns agent, gets ID 7efad0d8-5a78-415*
LLM: "Created subagent 'auth-login' (7efad0d8) using DeepInfra"
User: "What subagents do we have?"
LLM: *reads registry, displays table*
auth-login coder-pro DeepInfra ✓ done 20:00
User: "Resume auth-login and tell it to add password reset"
LLM: *reads registry, finds ID, resumes with same provider*
LLM: "Resumed 'auth-login' (7efad0d8) — DeepInfra cache warm"