CLI ToolsMar 30, 2026·1 min read

OpenAI Agents SDK — Multi-Agent Workflows in Python

Official OpenAI framework for building multi-agent workflows. Handoffs between agents, tool calling, guardrails, tracing, and streaming. Lightweight, Python-native. 20K+ stars.

TL;DR
OpenAI Agents SDK provides Python primitives for agent handoffs, tool calling, guardrails, and tracing in multi-agent systems.
§01

What it is

OpenAI Agents SDK is the official lightweight Python framework from OpenAI for building multi-agent workflows. It provides core primitives: Agents (LLMs with instructions and tools), Handoffs (delegation between specialized agents), Guardrails (input/output validation), and Tracing (execution observability). The SDK is designed to be minimal yet production-ready.

The SDK targets Python developers building multi-agent systems with OpenAI models. It works with GPT-4o, o3, and any OpenAI-compatible endpoint, making it suitable for both cloud and self-hosted model deployments.

§02

How it saves time or tokens

The SDK handles agent orchestration, context passing, and error recovery that you would otherwise build from scratch. Handoffs let specialized agents handle subtasks (billing, technical support, research) without routing logic in your application code. Guardrails validate inputs and outputs before and after agent runs, catching issues early and reducing wasted API calls.

§03

How to use

  1. Install the SDK: pip install openai-agents.
  2. Define agents with instructions and tools, and configure handoffs between them.
  3. Run the workflow with Runner.run_sync(agent, input) or the async equivalent.
§04

Example

from agents import Agent, Runner

# Define specialized agents
billing_agent = Agent(
    name='Billing',
    instructions='Handle billing questions and refunds.'
)

technical_agent = Agent(
    name='Technical',
    instructions='Handle technical support questions.'
)

# Triage agent delegates to specialists
triage = Agent(
    name='Triage',
    instructions='Route the user to the right agent.',
    handoffs=[billing_agent, technical_agent]
)

# Run the workflow
result = Runner.run_sync(triage, 'I need a refund for my last order.')
print(result.final_output)
§05

Related on TokRepo

§06

Common pitfalls

  • The SDK is optimized for OpenAI models; using non-OpenAI endpoints may require adjusting prompt formats for handoff instructions.
  • Guardrails run additional LLM calls for validation, which adds latency and cost; use them selectively on high-risk inputs.
  • Tracing generates detailed execution logs that can be verbose; configure log levels appropriately for production deployments.

Frequently Asked Questions

Can I use OpenAI Agents SDK with non-OpenAI models?+

The SDK works with any OpenAI-compatible endpoint, so you can point it at self-hosted models or third-party APIs that implement the OpenAI API format. However, handoff behavior is optimized for OpenAI models.

What is the difference between Agents SDK and LangGraph?+

Agents SDK is OpenAI's official, lightweight framework focused on handoffs and guardrails. LangGraph is LangChain's graph-based orchestrator with more complex state management. Choose Agents SDK for OpenAI-centric workflows and LangGraph for provider-agnostic graph-based agents.

How do handoffs work?+

When an agent determines a task should be handled by a specialist, it returns a handoff instruction. The SDK transfers the conversation context to the target agent automatically, preserving message history.

Are guardrails required?+

No. Guardrails are optional decorators you add to validate inputs or outputs. They are useful for filtering harmful content, enforcing format requirements, or implementing business rules.

Does the SDK support streaming?+

Yes. The SDK supports streaming responses through Runner.run_streamed(), which yields tokens as they are generated. This is useful for real-time chat interfaces.

Citations (3)
🙏

Source & Thanks

Created by OpenAI. Licensed under MIT. openai/openai-agents-python — 20,000+ GitHub stars

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets