Agentic AI Notebook
Phase 11

Sessions & Handoffs

~3 min read

Concept & How It Works

  • Key points are in the visual diagram above.

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.'
Loading diagram...

Visual Workflows

What is Sessions & Handoffs?

Loading diagram...

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 OpenAI Agents SDK, 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.

Sessions & Handoffs
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 openai-agents # OpenAI Agents SDK
  • python -c "from agents import Agent, Runner" # verify install

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