Troubleshoot handoffs
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)
Destination assistant ignores part of its system prompt
If a destination assistant has more than one system message in model.messages, only the first system message is sent to the model after a handoff. Any additional system messages are dropped. The same assistant follows all of its instructions when you call it directly.
To fix this, combine all system instructions into a single system message. Use the model field of the Update Assistant endpoint to replace model.messages with one system message. Include the full model object in your request, since the update replaces the existing model configuration.
For example, this configuration loses the second system message after a handoff:
Combine the instructions into one system message instead: