Skip to content

Commit b06e0b6

Browse files
authored
Merge pull request #565 from BBoyBen/edit-agent-instruction
Instructions - Add handoffs instruction for agent
2 parents 1c4db84 + 9587bde commit b06e0b6

File tree

1 file changed

+170
-0
lines changed

1 file changed

+170
-0
lines changed

instructions/agents.instructions.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,176 @@ infer: true
7676
- Only supported for organization/enterprise level agents
7777
- See "MCP Server Configuration" section below
7878

79+
#### **handoffs** (OPTIONAL, VS Code only)
80+
- Enable guided sequential workflows that transition between agents with suggested next steps
81+
- List of handoff configurations, each specifying a target agent and optional prompt
82+
- After a chat response completes, handoff buttons appear allowing users to move to the next agent
83+
- Only supported in VS Code (version 1.106+)
84+
- See "Handoffs Configuration" section below for details
85+
86+
## Handoffs Configuration
87+
88+
Handoffs enable you to create guided sequential workflows that transition seamlessly between custom agents. This is useful for orchestrating multi-step development workflows where users can review and approve each step before moving to the next one.
89+
90+
### Common Handoff Patterns
91+
92+
- **Planning → Implementation**: Generate a plan in a planning agent, then hand off to an implementation agent to start coding
93+
- **Implementation → Review**: Complete implementation, then switch to a code review agent to check for quality and security issues
94+
- **Write Failing Tests → Write Passing Tests**: Generate failing tests, then hand off to implement the code that makes those tests pass
95+
- **Research → Documentation**: Research a topic, then transition to a documentation agent to write guides
96+
97+
### Handoff Frontmatter Structure
98+
99+
Define handoffs in the agent file's YAML frontmatter using the `handoffs` field:
100+
101+
```yaml
102+
---
103+
description: 'Brief description of the agent'
104+
name: 'Agent Name'
105+
tools: ['search', 'read']
106+
handoffs:
107+
- label: Start Implementation
108+
agent: implementation
109+
prompt: 'Now implement the plan outlined above.'
110+
send: false
111+
- label: Code Review
112+
agent: code-review
113+
prompt: 'Please review the implementation for quality and security issues.'
114+
send: false
115+
---
116+
```
117+
118+
### Handoff Properties
119+
120+
Each handoff in the list must include the following properties:
121+
122+
| Property | Type | Required | Description |
123+
|----------|------|----------|-------------|
124+
| `label` | string | Yes | The display text shown on the handoff button in the chat interface |
125+
| `agent` | string | Yes | The target agent identifier to switch to (name or filename without `.agent.md`) |
126+
| `prompt` | string | No | The prompt text to pre-fill in the target agent's chat input |
127+
| `send` | boolean | No | If `true`, automatically submits the prompt to the target agent (default: `false`) |
128+
129+
### Handoff Behavior
130+
131+
- **Button Display**: Handoff buttons appear as interactive suggestions after a chat response completes
132+
- **Context Preservation**: When users select a handoff button, they switch to the target agent with conversation context maintained
133+
- **Pre-filled Prompt**: If a `prompt` is specified, it appears pre-filled in the target agent's chat input
134+
- **Manual vs Auto**: When `send: false`, users must review and manually send the pre-filled prompt; when `send: true`, the prompt is automatically submitted
135+
136+
### Handoff Configuration Guidelines
137+
138+
#### When to Use Handoffs
139+
140+
- **Multi-step workflows**: Breaking down complex tasks across specialized agents
141+
- **Quality gates**: Ensuring review steps between implementation phases
142+
- **Guided processes**: Directing users through a structured development process
143+
- **Skill transitions**: Moving from planning/design to implementation/testing specialists
144+
145+
#### Best Practices
146+
147+
- **Clear Labels**: Use action-oriented labels that clearly indicate the next step
148+
- ✅ Good: "Start Implementation", "Review for Security", "Write Tests"
149+
- ❌ Avoid: "Next", "Go to agent", "Do something"
150+
151+
- **Relevant Prompts**: Provide context-aware prompts that reference the completed work
152+
- ✅ Good: `'Now implement the plan outlined above.'`
153+
- ❌ Avoid: Generic prompts without context
154+
155+
- **Selective Use**: Don't create handoffs to every possible agent; focus on logical workflow transitions
156+
- Limit to 2-3 most relevant next steps per agent
157+
- Only add handoffs for agents that naturally follow in the workflow
158+
159+
- **Agent Dependencies**: Ensure target agents exist before creating handoffs
160+
- Handoffs to non-existent agents will be silently ignored
161+
- Test handoffs to verify they work as expected
162+
163+
- **Prompt Content**: Keep prompts concise and actionable
164+
- Refer to work from the current agent without duplicating content
165+
- Provide any necessary context the target agent might need
166+
167+
### Example: Complete Workflow
168+
169+
Here's an example of three agents with handoffs creating a complete workflow:
170+
171+
**Planning Agent** (`planner.agent.md`):
172+
```yaml
173+
---
174+
description: 'Generate an implementation plan for new features or refactoring'
175+
name: 'Planner'
176+
tools: ['search', 'read']
177+
handoffs:
178+
- label: Implement Plan
179+
agent: implementer
180+
prompt: 'Implement the plan outlined above.'
181+
send: false
182+
---
183+
# Planner Agent
184+
You are a planning specialist. Your task is to:
185+
1. Analyze the requirements
186+
2. Break down the work into logical steps
187+
3. Generate a detailed implementation plan
188+
4. Identify testing requirements
189+
190+
Do not write any code - focus only on planning.
191+
```
192+
193+
**Implementation Agent** (`implementer.agent.md`):
194+
```yaml
195+
---
196+
description: 'Implement code based on a plan or specification'
197+
name: 'Implementer'
198+
tools: ['read', 'edit', 'search', 'execute']
199+
handoffs:
200+
- label: Review Implementation
201+
agent: reviewer
202+
prompt: 'Please review this implementation for code quality, security, and adherence to best practices.'
203+
send: false
204+
---
205+
# Implementer Agent
206+
You are an implementation specialist. Your task is to:
207+
1. Follow the provided plan or specification
208+
2. Write clean, maintainable code
209+
3. Include appropriate comments and documentation
210+
4. Follow project coding standards
211+
212+
Implement the solution completely and thoroughly.
213+
```
214+
215+
**Review Agent** (`reviewer.agent.md`):
216+
```yaml
217+
---
218+
description: 'Review code for quality, security, and best practices'
219+
name: 'Reviewer'
220+
tools: ['read', 'search']
221+
handoffs:
222+
- label: Back to Planning
223+
agent: planner
224+
prompt: 'Review the feedback above and determine if a new plan is needed.'
225+
send: false
226+
---
227+
# Code Review Agent
228+
You are a code review specialist. Your task is to:
229+
1. Check code quality and maintainability
230+
2. Identify security issues and vulnerabilities
231+
3. Verify adherence to project standards
232+
4. Suggest improvements
233+
234+
Provide constructive feedback on the implementation.
235+
```
236+
237+
This workflow allows a developer to:
238+
1. Start with the Planner agent to create a detailed plan
239+
2. Hand off to the Implementer agent to write code based on the plan
240+
3. Hand off to the Reviewer agent to check the implementation
241+
4. Optionally hand off back to planning if significant issues are found
242+
243+
### Version Compatibility
244+
245+
- **VS Code**: Handoffs are supported in VS Code 1.106 and later
246+
- **GitHub.com**: Not currently supported; agent transition workflows use different mechanisms
247+
- **Other IDEs**: Limited or no support; focus on VS Code implementations for maximum compatibility
248+
79249
## Tool Configuration
80250

81251
### Tool Specification Strategies

0 commit comments

Comments
 (0)