Cette page est affichée en anglais. Une traduction française est en cours.
SkillsApr 7, 2026·2 min de lecture

OpenAI Agents SDK — Build Multi-Agent Systems in Python

Official OpenAI Python SDK for building multi-agent systems with handoffs, guardrails, and tracing. Agents delegate to specialists, enforce safety rules, and produce observable traces. 8,000+ stars.

OpenAI
OpenAI · Community
Prêt pour agents

Installation avec revue préalable

Cet actif nécessite une revue. Le prompt copié demande un dry-run, affiche les écritures, puis continue seulement après confirmation.

Needs Confirmation · 66/100Policy : confirmer
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Community
Point d'entrée
OpenAI Agents SDK — Build Multi-Agent Systems in Python
Commande avec revue préalable
npx -y tokrepo@latest install 38035d0b-f942-4bf2-bbad-be9d4f719c00 --target codex

Dry-run d'abord, confirmez les écritures, puis lancez cette commande.

TL;DR
Official OpenAI SDK for multi-agent systems with handoffs, guardrails, and tracing in Python.
§01

What it is

The OpenAI Agents SDK is the official Python framework for building multi-agent systems. It provides primitives for creating agents that delegate tasks to specialist sub-agents (handoffs), enforce safety constraints (guardrails), and produce observable execution traces. Each agent has its own instructions, tools, and model configuration, and agents can hand off conversations to each other based on the task at hand.

Developers building complex AI applications that require task decomposition, specialist routing, or safety guardrails benefit from this SDK. It is designed for production use with OpenAI models.

§02

How it saves time or tokens

The SDK handles the orchestration complexity of multi-agent systems: routing, context passing, safety checks, and trace collection. Without it, developers build these patterns from scratch with custom code. The handoff mechanism lets you use cheaper models for simple tasks and route complex tasks to more capable models, optimizing token costs across the system.

§03

How to use

  1. Install the SDK via pip
  2. Define agents with instructions, tools, and handoff rules
  3. Run the agent system with Runner and inspect traces
§04

Example

from agents import Agent, Runner

triage = Agent(
    name='triage',
    instructions='Route user questions to the right specialist.',
    handoffs=['coder', 'writer']
)

coder = Agent(
    name='coder',
    instructions='You write Python code to solve problems.',
    model='gpt-4o'
)

writer = Agent(
    name='writer',
    instructions='You write clear, concise documentation.',
    model='gpt-4o-mini'
)

result = Runner.run_sync(
    triage,
    messages=[{'role': 'user', 'content': 'Write a Python function to parse CSV'}]
)
print(result.final_output)
§05

Related on TokRepo

§06

Common pitfalls

  • Handoff loops can occur if agents keep routing to each other; set clear handoff conditions and a maximum depth
  • Guardrails add latency to each agent turn; test performance impact before adding many validators
  • The SDK is tightly coupled to OpenAI models; using it with other providers requires an OpenAI-compatible API proxy

Questions fréquentes

Does the Agents SDK work with non-OpenAI models?+

The SDK is designed for OpenAI models. You can use it with OpenAI-compatible API endpoints (like LiteLLM or vLLM) by pointing the base URL. Native support for Anthropic or Google models is not included.

What are handoffs?+

Handoffs let one agent delegate a conversation to another specialized agent. The triage agent decides which specialist should handle the request and passes the conversation context. This enables task decomposition across multiple agents.

How does tracing work?+

The SDK automatically records execution traces including agent turns, tool calls, handoffs, and guardrail evaluations. Traces can be viewed in the OpenAI dashboard or exported for custom analysis.

Can I add custom tools to agents?+

Yes. Agents can use custom Python functions as tools. Decorate a function with @tool, and the agent can call it during execution. Tools can access databases, APIs, file systems, or any Python-accessible resource.

Is the Agents SDK free?+

The SDK itself is open-source and free. You pay for the OpenAI API calls that agents make. Costs depend on which models you configure for each agent and how many turns each task requires.

Sources citées (3)
🙏

Source et remerciements

Created by OpenAI. Licensed under MIT.

openai-agents-python — stars 8,000+

Thanks to OpenAI for standardizing multi-agent patterns.

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires