Troubleshoot handoffs
Diagnose handoffs that never fire, starting with the system prompt
A handoff that never fires is almost always a prompting problem rather than a configuration one. The model has to be told when to call the tool. Start with the system prompt guidance below, then work through the remaining checks.
System prompt best practices
When using the Handoff tool, add this to your system prompt for optimal agent coordination (adapted from the OpenAI Agents Handoff Prompt):
Best practices
- Clear descriptions: Write specific, actionable descriptions for each destination in your system prompt. Use
tool.function.nameto customize the name of the function to reference in your prompt. - Context management: Use
lastNMessagesoruserAndAssistantMessagesto limit context size for performance. - Model optimization: Use multiple tools for OpenAI, single tool for Anthropic.
- Variable extraction: Extract key data before handoff to maintain context across assistants.
- Tool messages: Add custom
request-startmessages to set caller expectations during transfers. - Testing: Test handoff scenarios thoroughly, including edge cases and rejection conditions.
- Monitoring and analysis: Enable
artifactPlan.fullMessageHistoryEnabledto capture the complete message history across all handoffs in your artifacts. See squad artifact behavior for details.
Troubleshooting
- Ensure assistant IDs are valid and accessible
- Verify webhook server URLs are reachable and return the proper format
- Check that required parameters in custom functions match destinations
- Monitor context size to avoid token limits
- Test variable extraction schemas with sample data
- Validate that assistant names exist in the same squad
- Verify rejection plan conditions use correct regex syntax (remember to double-escape
\\in JSON)