Scripts2026年3月30日·1 分钟阅读

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.

TO
TokRepo精选 · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

pip install openai-agents
from agents import Agent, Runner

agent = Agent(name="Assistant", instructions="You are a helpful assistant.")
result = Runner.run_sync(agent, "Write a haiku about coding.")
print(result.final_output)

介绍

OpenAI Agents SDK is the official lightweight Python framework for building multi-agent workflows. It provides primitives for agent handoffs, tool calling, input/output guardrails, tracing, and streaming — designed to be minimal yet production-ready. 20,000+ GitHub stars, maintained by OpenAI.

Best for: Developers building multi-agent systems with OpenAI models Works with: OpenAI API, GPT-4o, o3, any OpenAI-compatible endpoint


Core Concepts

Agents

Agents are LLMs configured with instructions and tools:

agent = Agent(
    name="Research Agent",
    instructions="You research topics thoroughly.",
    tools=[search_tool, wikipedia_tool],
)

Handoffs

Agents can delegate to specialized agents:

triage = Agent(
    name="Triage",
    handoffs=[billing_agent, technical_agent, general_agent],
)

Guardrails

Validate inputs/outputs before and after agent runs:

@input_guardrail
async def check_topic(ctx, agent, input):
    # reject off-topic requests
    ...

Tracing

Built-in tracing for debugging multi-agent flows — visualize handoff chains, tool calls, and token usage.


FAQ

Q: What is OpenAI Agents SDK? A: The official OpenAI Python framework for multi-agent workflows with handoffs, tool calling, guardrails, and tracing. 20K+ GitHub stars.

Q: How is it different from LangChain or CrewAI? A: It's minimal by design — focused primitives (agents, handoffs, guardrails) without a large dependency tree. Built and maintained by OpenAI.


🙏

来源与感谢

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

相关资产