Esta página se muestra en inglés. Una traducción al español está en curso.
SkillsApr 7, 2026·2 min de lectura

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.

Listo para agents

Instalación con revisión previa

Este activo requiere revisión. El prompt copiado pide dry-run, muestra escrituras y continúa solo tras confirmación.

Needs Confirmation · 66/100Política: confirmar
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Community
Entrada
OpenAI Agents SDK — Build Multi-Agent Systems in Python
Comando con revisión previa
npx -y tokrepo@latest install 38035d0b-f942-4bf2-bbad-be9d4f719c00 --target codex

Primero dry-run, confirma las escrituras y luego ejecuta este comando.

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

Preguntas frecuentes

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.

Referencias (3)
🙏

Fuente y agradecimientos

Created by OpenAI. Licensed under MIT.

openai-agents-python — stars 8,000+

Thanks to OpenAI for standardizing multi-agent patterns.

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados