DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk4 min

Building a Simple Multi-Agent Workflow in Python: Router + Specialist Agents

A router-plus-specialists workflow in Python turns on one decision: should the chosen specialist answer directly, or should a manager call it and keep the final reply? Here is how to build it with the OpenAI Agents SDK.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A router-plus-specialists workflow is one triage agent that reads each request and sends it to a narrowly scoped specialist. The design decision that matters most is ownership: does the chosen specialist answer the user directly, or does a manager agent call the specialist for a bounded subtask and keep responsibility for the final reply? The OpenAI Agents SDK for Python implements these as handoffs and agents-as-tools, and choosing between them should come before you write any routing code.

Start with one agent that runs end to end

The official Python quickstart recommends getting a single agent working before adding routing, tools, or state. Its own guidance is to add capabilities incrementally once the first loop works. OpenAI’s Python quickstart documents the steps below.

  1. Create a virtual environment and install the package with pip install openai-agents.
  2. Configure your OpenAI credentials as the quickstart describes before running anything.
  3. Import Agent and Runner from the agents module.
  4. Run the agent asynchronously with Runner.run(...) and read the answer from result.final_output.

A minimal run looks like this:

import asyncio
from agents import Agent, Runner

async def main():
    agent = Agent(name="Assistant", instructions="You are a helpful assistant.")
    result = await Runner.run(agent, "Name two differences between handoffs and agents-as-tools.")
    print(result.final_output)

asyncio.run(main())

Confirm this prints a sensible answer before you add a second agent. Most routing bugs are easier to diagnose when the single-agent loop is already known to work.

Choose the control flow before writing the router

The SDK’s orchestration guide frames multi-agent work around one question: who should own the next response? It describes two patterns, and the router design follows from the answer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Decision axis Handoffs Agents-as-tools
Who owns the next response? The selected specialist takes over that branch. The manager remains in control.
Best fit Routing is part of the workflow and the specialist should respond directly. Specialist work is bounded, and a manager should combine outputs or own the final response.
Specialist context A handoff receives conversation history by default; filters and configuration can narrow it. The specialist runs as a tool for a task while the manager keeps ownership of the answer.

Sources: the OpenAI Agents SDK agent orchestration guide and the Python handoffs guide.

As a rule of thumb, use handoffs for a support-style triage where a billing or refund specialist should speak to the customer directly. Use agents-as-tools when a manager needs several specialist outputs and must write one coherent reply.

Build the router and specialists

Define one router or triage role

The router’s only job is selection. Its instructions should say which specialists exist and when each one applies. The quickstart’s routing material uses a triage agent with separate handoff destinations, which is the pattern to copy. The specific sample on that page is JavaScript; the Python equivalent should be written from the Python handoff documentation, not translated from that snippet.

Keep specialists small and non-overlapping

Give each specialist distinct instructions and a narrow scope. Overlap is the most common cause of misrouting: if two specialists could plausibly answer a request, the router has no reliable basis for choosing. The Python handoff guide notes that a specialist’s handoff description can guide the model’s choice of destination, so write each description as a short statement of what that specialist handles and what it does not.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Register each handoff destination explicitly

Each specialist that the router may reach should be registered as its own handoff destination. The SDK exposes those destinations for selection. The Python handoff guide also documents optional customization: descriptions, callbacks, input schemas, and input filters. Use only the options you need for the first version.

Limit the context each specialist receives

Handoffs normally carry conversation history to the receiving agent. That is useful when the specialist needs the whole exchange, but it can leak irrelevant detail to a narrow specialist. Use input filters or history configuration when a specialist should see less. For agents-as-tools, pass the manager’s bounded task rather than the full transcript unless the specialist truly needs it.

Handle later turns deliberately

A single Runner.run call continues through tool calls and handoffs until the runtime reaches a stopping point. That loop is the within-run boundary. Conversation state across separate runs is a different problem, and the OpenAI running-agents guide distinguishes the two. For the second turn onward, pick one strategy and apply it consistently:

  • Application-held history: your code stores the messages and passes them back on each run.
  • A session: the SDK’s session support maintains continuity across runs.
  • A conversation ID: the platform keeps the conversation under an identifier you pass back.
  • A previous response ID: each new turn references the response that came before it.

Mixing strategies is a common source of duplicated or missing context, so decide before the second turn ships.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Add guardrails and tracing only when the example needs them

The SDK overview lists guardrails, sessions, and tracing as built-in capabilities. Guardrails help with validation, sessions with continuity, and tracing with seeing what each agent did during a run. Add them when a specific problem calls for them: misrouted requests, lost context, or unclear failures. Their presence in the SDK does not by itself make the workflow correct, so test routing decisions with your own representative requests.

What the official sources do and do not establish

The official documentation establishes the install command, the basic async run, the two orchestration patterns, the handoff configuration options, and the state distinction described above. It does not establish performance, reliability, or cost figures for router designs, and it does not offer a cross-framework comparison. Treat any claim that one orchestration style is faster or cheaper as unverified unless you measure it in your own application.

The orchestration guide contains this sentence, which is a good summary of the ownership rule: “Use handoffs when routing itself is part of the workflow and you want the chosen specialist to own the remainder of the current turn.” It is documentation wording rather than a quotation from a named person.

“

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.