Skip to content

Commit 0dd0437

Browse files
committed
feat: add guidance for decomposing multi-step protocols into sub-agents in squad-creator SKILL.md
1 parent 8828d91 commit 0dd0437

2 files changed

Lines changed: 75 additions & 1 deletion

File tree

.github/skills/agent-customization/SKILL.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ VS Code also detects plain `.md` files in `.github/agents/`.
6868
The body is prepended to every user prompt when the agent is active. Keep it focused and
6969
purposeful — include only what genuinely changes the agent's behavior.
7070

71-
For the full list of frontmatter properties, read `references/frontmatter.md`.
71+
For the full list of frontmatter properties, read `references/frontmatter.md`.
7272
For all available tool names, read `references/tools.md`.
7373

7474
---
@@ -173,6 +173,73 @@ See `references/patterns.md` for an orchestrator pattern.
173173

174174
---
175175

176+
## Multi-Step Protocols and Sub-Agents
177+
178+
When an agent body has a numbered protocol with **distinct, independent steps**, each
179+
step should be delegated to a separate sub-agent invocation rather than executed in a
180+
single context. This prevents context window bloat, reduces interference between steps,
181+
and allows independent steps to run in parallel.
182+
183+
### When to apply this pattern
184+
185+
Use sub-agents for individual protocol steps when **all** of these are true:
186+
- The agent has 3 or more protocol steps
187+
- Each step has a clearly different focus (e.g., explore, implement, verify)
188+
- Steps do not need to carry the full accumulated context of earlier steps
189+
190+
### How to write the protocol
191+
192+
Instead of describing steps as inline instructions, tell the agent to invoke a
193+
sub-agent for each step:
194+
195+
````markdown
196+
## Protocol
197+
198+
This agent executes each step in a separate sub-agent to keep contexts lean.
199+
200+
### Step 1 — <name>
201+
Invoke a sub-agent with: "<instruction for step 1 only>"
202+
Output: write result to `/memories/session/<step1>.md`
203+
204+
### Step 2 — <name>
205+
Read `/memories/session/<step1>.md`, then invoke a sub-agent with: "<instruction>"
206+
Output: write result to `/memories/session/<step2>.md`
207+
208+
### Step 3 — <name> (parallel with Step 2 if independent)
209+
Invoke a sub-agent in the **same turn** as Step 2 with: "<instruction>"
210+
Output: write result to `/memories/session/<step3>.md`
211+
````
212+
213+
### Parallel steps
214+
215+
When two steps don't depend on each other's output, invoke their sub-agents **in the
216+
same turn**. Annotate this clearly in the protocol:
217+
218+
```
219+
② Step A ┐ invoke in the same turn
220+
② Step B ┘
221+
③ Step C (depends on A and B — invoke after both finish)
222+
```
223+
224+
### Frontmatter requirements
225+
226+
An agent that delegates steps to sub-agents must have `agent` in its `tools` list.
227+
Use `agents: ['*']` if the sub-agents are ad-hoc (no named `.agent.md` files). Use a
228+
named list when the sub-agents are fixed specialist agents.
229+
230+
```yaml
231+
tools: ['search', 'read', 'vscode/memory', 'agent']
232+
agents: ['*']
233+
```
234+
235+
### Memory handoff between steps
236+
237+
Sub-agents communicate exclusively through `vscode/memory`. The parent agent writes
238+
a brief for each step before invoking it, and the sub-agent writes its output to a
239+
dedicated memory file when done. The parent reads that file before invoking the next step.
240+
241+
---
242+
176243
## Security Considerations
177244

178245
- Grant agents only the tools they actually need (principle of least privilege)

.github/skills/squad-creator/SKILL.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ Each specialist should:
235235
5. **Run verification** where applicable (build, tests, lint) and report results.
236236
6. **Include an authentication-failure protocol** if the agent calls external services:
237237
stop and report to the Orchestrator rather than retrying silently.
238+
7. **Decompose multi-step protocols into sub-agents.** If the specialist has 3 or more
239+
distinct protocol steps (e.g., explore, implement, verify), write the body so that
240+
each step is delegated to a separate sub-agent invocation rather than executed in a
241+
single context. Add `agent` to the specialist's `tools` and use `agents: ['*']` for
242+
ad-hoc sub-agents. Independent steps should be invoked in the same turn (parallel).
243+
See **Multi-Step Protocols and Sub-Agents** in `agent-customization/SKILL.md`.
238244

239245
---
240246

@@ -261,4 +267,5 @@ Before handing back to the user, confirm:
261267
- [ ] Memory paths are consistent across the squad
262268
- [ ] Parallel sections clearly annotated in Orchestrator workflow
263269
- [ ] `vscode/askQuestions` included in tools for agents that may need user input
270+
- [ ] Specialists with 3+ protocol steps use sub-agents per step (`agent` in tools, steps invoke sub-agents)
264271
- [ ] User was shown the final squad design and confirmed it

0 commit comments

Comments
 (0)