Demonstrates advanced handoff configuration including callbacks, structured inputs, and custom tool naming.
Sign in to save downloads to your library and vote.
Preview
Advanced Handoffs
Demonstrates advanced handoff configuration including callbacks, structured inputs, and custom tool naming.
๐ฏ What This Demonstrates
- Custom Handoff Configuration: Using the
handoff()function - Callback Functions: Executing code when handoffs are triggered
- Structured Input Data: Passing specific data with handoffs
- Tool Customization: Custom tool names and descriptions
๐ Quick Start
-
Install OpenAI Agents SDK:
pip install openai-agents -
Set up environment:
cp ../env.example .env # Edit .env and add your OpenAI API key -
Run the agent:
import asyncio from agent import main # Test advanced handoffs asyncio.run(main())
๐ก Key Concepts
- handoff() Function: Custom handoff configuration
- Callback Execution: on_handoff functions for tracking
- Structured Input: Pydantic models for handoff data
- Tool Overrides: Custom tool names and descriptions
๐งช Advanced Features
Escalation with Structured Data
class EscalationData(BaseModel):
reason: str
priority: str
customer_id: str
escalation_handoff = handoff(
agent=escalation_agent,
tool_name_override="escalate_to_manager",
input_type=EscalationData
)
Callback Functions
async def on_escalation_handoff(ctx, input_data):
print(f"๐จ ESCALATION: {input_data.reason}")
# Log to monitoring system
# Send notifications
# Update tickets
Custom Tool Configuration
- tool_name_override: Custom tool names
- tool_description_override: Custom tool descriptions
- input_filter: Control what context transfers
- is_enabled: Dynamic handoff enabling/disabling
๐ป Advanced Patterns
Escalation Handoff
- Angry customer scenarios
- High-value refund requests
- Complex technical issues
Callback Integration
- Logging and monitoring
- Notification systems
- Metric tracking
Input Filtering
- Context cleaning
- Sensitive data removal
- Conversation sanitization
๐ Next Steps
- Basic Handoffs - Handoff fundamentals
- Tutorial 9: Multi-Agent Orchestration - Complex workflows
Ingestion metadata
- Source catalog
- awesome-llm-apps
- Repository
- Shubhamsaboo/awesome-llm-apps ยท main
- File path
- ai_agent_framework_crash_course/openai_sdk_crash_course/8_handoffs_delegation/8_2_advanced_handoffs/README.md
- Last refreshed
- 10/24/2026, 3:00:14 AM (5h ago)
- Refresh schedule
- Daily ยท 03:00 UTC
- Dedupe status
- Unique ยท deduped by (source, url)