OpenAI Agents SDK
OpenAI Agents SDK is an open-source development framework released by OpenAI for building agent-based applications. It provides developers with core capabilities for creating, orchestrating, and managing AI agents, supporting multi-agent collaboration, tool calling, conversation context management, and execution tracing. The framework is designed to simplify the development of autonomous task-planning and execution systems built on large language models.
Core Facts
OpenAI open-sourced the experimental framework Swarm in 2024, proposing a lightweight Agent-to-Agent handoff mechanism.
If a product is built on OpenAI, the OpenAI Agents SDK is the best choice, with excellent built-in support for tool calls, handoffs, tracing, guardrails, and multi-step execution.
Major AI companies such as OpenAI and Anthropic all provide official Python-based SDKs.
Timeline (last 90 days)
The Pink repository provides runnable examples for LangGraph, OpenAI Agents SDK, CrewAI, and Vercel AI SDK.
A survey of 12 mainstream Agent frameworks found that none of the frameworks provides monetary-denominated tool-call budget control in its documentation (C5 is all no).
在 OpenAI Agents SDK 中,Runner.run_stream 是流式异步执行方式,LLM 每识别出一小段内容就立即推送到缓冲区并打印到终端,而不是等整段响应生成完再一次性显示。
在 OpenAI Agents SDK 中,异步调用使用 Runner.run 必须配合 await 关键字;如果只写 Runner.run(...) 而不加 await,得到的是一个未执行的 coroutine 对象。
在 OpenAI Agents SDK 中,Runner.run_sync 是同步调用方式,会立即返回响应,但无法在 Jupyter Notebook 中运行,因为 Notebook 自身已运行着事件循环,嵌套启动新循环会抛出 'This event loop is already running' 错误。
使用 OpenAI Agents SDK 时,环境变量名必须严格写为 OPENAI_API_KEY,否则 SDK 将无法识别。
安装 OpenAI Agents SDK 的命令是 pip install openai-agents。
OpenAI Agents SDK 同时提供 Python 和 JavaScript 两个版本。
OpenAI Agents SDK 的 RunResult 对象包含本次运行的全部细节:原始输入、最终输出、最后响应的 Agent、使用了哪些工具、连接的 Agent 数量、以及 token 消耗统计。
Pink团队调查了12个主流Agent框架(LangChain/LangGraph、CrewAI、OpenAI Agents SDK、Vercel AI SDK、Google ADK、AutoGen、Semantic Kernel、LlamaIndex、Pydantic AI、Mastra、Claude Agent SDK、smolagents),其中0个文档化了以货币计价的工具调用支出预算。
40 more timeline events
All Facts (20)
OpenAI open-sourced the experimental framework Swarm in 2024, proposing a lightweight Agent-to-Agent handoff mechanism.
80%VerifiedIf a product is built on OpenAI, the OpenAI Agents SDK is the best choice, with excellent built-in support for tool calls, handoffs, tracing, guardrails, and multi-step execution.
70%VerifiedMajor AI companies such as OpenAI and Anthropic all provide official Python-based SDKs.
70%VerifiedOpenAI's Agent SDK takes a more engineering-oriented approach, natively supporting agent-to-agent hand-off mechanisms and built-in safety guardrails.
65%VerifiedIn the tool-calling mechanism, developers attach a tool description list in JSON Schema format when calling the LLM API, and the model outputs call parameters in structured JSON format
65%VerifiedOpen Agent Builder natively supports the MCP protocol and can connect to existing MCP tool servers in the community.
65%VerifiedThe OpenAI Agents SDK's trace function supports adding custom metadata, which can be used to filter and analyze trace records.
65%VerifiedThe instructions parameter in the OpenAI Agents SDK is essentially a system prompt, used to define the behavioral guidelines of the Agent.
65%VerifiedThe official OpenAI Python SDK released version v3.23.0, with enhanced Agents capabilities as the main theme.
90%UnverifiedAgents SDK提供了trace函数作为上下文管理器,支持workflow_name和group_id两个关键参数用于自定义追踪
95%UnverifiedOpenAI Agents SDK定义了五种消息类型:Developer Message、User Message、Assistant Message、Function Call和Function Call Output
95%UnverifiedOpenAI Agents SDK的Runner不会自动保存和维护对话历史,每次调用Runner.run()都是独立的
95%UnverifiedOpenAI Agents SDK内置了WebSearchTool,可用于Agent的Web搜索功能
90%UnverifiedOpenAI Agents SDK使用to_input_list()方法将上一次的运行结果转换为可重新输入的格式,以实现对话历史的手动管理
90%Unverified2024-2025年,Anthropic Claude Agent SDK、OpenAI Agents SDK、Google ADK等Agent框架集中涌现
85%UnverifiedOpenAI Agents SDK支持gpt-4.1-nano和gpt-4.1-mini等模型
85%UnverifiedOpenAI Agents SDK的无状态设计与LangChain的Memory模块等有状态框架形成对比
85%Unverifiedgroup_id的设计借鉴了分布式追踪领域的Trace Context标准(如W3C TraceContext),用于将相关追踪记录归为一组
70%UnverifiedThe OpenAI Agents SDK provides a Guardrails mechanism for intercepting inputs that should not enter the model and outputs that should not be returned to the user.
60%UnverifiedScriptedModel is a test helper class provided by the OpenAI Agents SDK that allows pre-defining static response sequences to drive Agent execution in place of a real LLM.
60%