Skills2026年4月7日·1 分钟阅读

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.

Agent 就绪

先审查再安装

这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。

Needs Confirmation · 66/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Community
入口
OpenAI Agents SDK — Build Multi-Agent Systems in Python
先审查命令
npx -y tokrepo@latest install 38035d0b-f942-4bf2-bbad-be9d4f719c00 --target codex

先 dry-run,确认写入项后再运行此命令。

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

常见问题

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.

引用来源 (3)
🙏

来源与感谢

Created by OpenAI. Licensed under MIT.

openai-agents-python — stars 8,000+

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产