Skip to content

How does orchestrator route follow-ups when handoff events aren't stored in conversation history? #2055

@Jash271

Description

@Jash271

Please read this first

  • Have you read the docs?Agents SDK docs -> Yes
  • Have you searched for related issues? Others may have had similar requests -> Yes

Question

I'm building a multi-agent system where an Orchestrator routes to specialized agents:

Orchestrator → QA Agent (retrieves content, answers questions)
Orchestrator → Revision Agent (generates quizzes, practice materials)

Each specialized agent can ask follow-up questions to the user. This is a simple example, but the system will grow with more agents and complex handoff chains (e.g., QA Agent → Response Generator, Revision Agent → Quiz Validator, etc.).

Current Pattern

# Every user message (including follow-ups):
orchestrator, session = build_orchestrator(session_id)
runner = Runner()
result = runner.run_streamed(
    orchestrator,  # Always start with orchestrator
    input=user_message,
    session=session
)

Scenario:

User: "Help me understand photosynthesis" → Orchestrator → QA Agent
QA Agent asks: "Do you want to focus on light reactions or dark reactions?"
User: "Light reactions" ← This is a follow-up
When the user responds, I call Runner.run() with the orchestrator again (same session). How does the orchestrator know to route back to QA Agent (not Revision Agent)? I'm using SQLAlchemySession and checking agent_messages.message_data and I don't see any handoff events being persisted

Question:

If handoff events aren't persisted in the messages column, how does the orchestrator determine:
That it previously handed off to QA Agent (not Revision Agent)?
That the follow-up "Light reactions" should continue with QA Agent?

Is the routing decision purely LLM-based (analyzing conversation content), or does the session track handoff state somewhere I'm not seeing? Or am I missing something

Some thoughts :

Would it make sense to:
Store handoff events in agent_messages.message_data

Track last_active_agent in the agent_sessions table?
Then explicitly guide the LLM by appending to orchestrator instructions:
The last agent that ran was: {last_active_agent}
Use the conversation context to decide which agent to call next.

Or is the general direction that users store the last agent that run from the run_results and incase of multi turn conversations call the last_run_agent ( which again becomes tricky to manage as the user message could indicate handing off to another agent or doing something completely different )

This becomes critical as the number of agents and handoff complexity grows. Any guidance on the correct pattern for multi-turn conversations with multiple specialized agents would be appreciated!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions