Sessions & Handoffs
~3 min read
Concept & How It Works
Why Does It Exist?
Users don't repeat themselves when switching specialists. Handoffs let you build modular agent teams without one mega-prompt that knows everything.
Real-World Analogy
A handoff is transferring a phone call with warm context: 'I'm connecting you to billing — they already know your invoice number.'
Visual Workflows
What is Sessions & Handoffs?
Example
Scenario
User asks about a bug → Triage hands to Engineering Agent → Engineering fixes and hands back to Triage for a user-friendly summary.
Solution
In Agent Frameworks, apply Sessions & Handoffs to this scenario: User asks about a bug → Triage hands to Engineering Agent → Engineering fixes and hands back to Triage for a user-friendly summary. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.
Practice Task
Do this before moving to the next module — reading alone is not enough.
Open the Code Walkthrough below and run it locally. Change one parameter related to Sessions & Handoffs (e.g. model, temperature, top_k, or tool name), observe the difference in output, and write 2–3 sentences explaining what changed.
Code Walkthrough
Highlighted lines show where Sessions & Handoffs happens in the code.
1from agents import Agent, handoff # import dependencies2
3engineering = Agent(name="Engineering", instructions="Debug technical issues.")4triage = Agent(5 name="Triage",6 instructions="Route technical issues to engineering.",7 handoffs=[handoff(engineering)], # key line for Sessions & Handoffs8)Commands to Remember
Commands to Remember
pip install langgraph langchain-openai # LangGraph agent frameworkpip install openai-agents # OpenAI Agents SDKpip install crewai # multi-agent CrewAI framework
Common Mistakes
- Treating Sessions & Handoffs as a black box without evaluation
- Ignoring cost and latency in production
- Skipping error handling for openai sessions handoffs
Cheat Sheet
Quick recap — the most important points from this module.
Cheat Sheet
quick ref- •Sessions & Handoffs
- •session_id
- •Warm Transfer
- •Context Filtering