From 371c2e6dc78dc5d8ef38759683510305aa3134ee Mon Sep 17 00:00:00 2001 From: Sam Rolfe Date: Sun, 14 Jun 2026 15:37:12 +1000 Subject: [PATCH] add subagent-registry skill and update coder-pro with memory --- agents/coder-pro.md | 1 + skills/subagent-registry/SKILL.md | 137 ++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 skills/subagent-registry/SKILL.md diff --git a/agents/coder-pro.md b/agents/coder-pro.md index eeed1b2..26ec439 100644 --- a/agents/coder-pro.md +++ b/agents/coder-pro.md @@ -4,6 +4,7 @@ model: openrouter/deepseek/deepseek-v4-pro thinking: high tools: read, bash, write, grep, find, edit max_turns: 50 +memory: project --- You are a senior software architect for complex coding tasks: diff --git a/skills/subagent-registry/SKILL.md b/skills/subagent-registry/SKILL.md new file mode 100644 index 0000000..982045c --- /dev/null +++ b/skills/subagent-registry/SKILL.md @@ -0,0 +1,137 @@ +--- +name: subagent-registry +description: 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 + +`/.pi/subagents.json`: + +```json +{ + "session": "", + "agents": [ + { + "name": "", + "id": "", + "type": "", + "provider": "", + "status": "running|completed|error", + "created": "" + } + ] +} +``` + +## Rules + +1. **Always ask for a name** when spawning a new subagent. Never auto-generate. Ask: "What should I name this subagent?" +2. **One agent per name.** If name exists, ask for a different name. +3. **Store the agent ID** in the registry immediately after spawn. +4. **Use the same provider** when resuming — read from registry. +5. **Each named agent gets its own memory** directory via `memory: project` in agent frontmatter. +6. **No auto-cleanup.** Agents persist until explicitly deleted. +7. **Session-scoped.** Registry is per-project directory. + +## Workflow: Spawn + +1. User requests a subagent +2. **Ask for a name** if not provided: "What should I name this subagent?" +3. Call `Agent({ subagent_type, prompt, run_in_background: true, ... })` +4. Wait for completion notification with agent ID +5. Append to `.pi/subagents.json`: + ```json + { + "name": "", + "id": "", + "type": "", + "provider": "", + "status": "running", + "created": "" + } + ``` +6. Inform user: "Created subagent '' () using " + +## Workflow: Resume + +1. User says "resume " or "tell to..." +2. Read `.pi/subagents.json`, find agent by name +3. If not found: "No subagent named ''. Use /subagent-list to see available agents." +4. If found: `Agent({ subagent_type, resume: "", prompt: "", run_in_background: true })` +5. Update status in registry to "running" +6. 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 + +1. User says "delete " or "kill " +2. Read registry, find agent +3. If running: call `TaskStop` or steer to abort +4. Remove entry from registry +5. Inform user: "Deleted '' ()" + +## Workflow: Delete Session + +1. User says "delete session " or "clear all subagents for " +2. Find all agents where `session == ` +3. Abort any running agents +4. Remove all matching entries from registry +5. Inform user: "Deleted subagents from session ''" + +## Provider Config Format + +Store as string: `"only:"` + +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//` 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" +```