OpenAI Agents API
346 points
• 4 days ago
• Article
Link
Agents API 为开发者提供了一种通过托管的 Codex harness 构建持久化云端 agent 的方式。该架构让 OpenAI 负责会话管理、编排、上下文压缩和恢复等复杂底层工作,而开发者则保留对执行环境以及 agent 可访问具体工具的控制权。将这些后端职责交由平台处理后,开发者可以专注于打造用于调查警报、审阅文档或与各类软件平台交互等专业任务的 agent 。
系统的核心由四个基本概念构成:agent 、 environment 、 session 和 events 。 agent 由其指定的模型、指令、工具以及可能需要的 Model Context Protocol (MCP) 服务器定义;environment 可以是由 OpenAI 托管的沙箱,也可以是自托管的沙箱,为 agent 提供运行代码、编辑文件和发挥能力的安全空间。 session 是 agent 持续工作的持久实例,events 则记录这些交互过程中产生的输入与输出。
托管的 harness 提供了一整套增强性能与可靠性的功能,支持在沙箱中执行代码、应用多种技能并连接外部数据源。 API 还便于对 agent 进行主动管理,包括在任务过程中引导 agent 、总结过往工作以优化上下文窗口,以及将复杂目标委派给子代理。
要开始使用,开发者需创建一个 session 、配置 agent 的能力并提供初始任务。环境准备就绪后 agent 会开始处理,开发者可通过流式传输或 webhook 监控进度。由于 API 会维护会话状态,agent 能无缝恢复工作而无需重建对话历史。需要注意的是,Agents API 目前要求数据驻留在 United States,且不支持 Zero Data Retention 。
The Agents API offers developers a way to build durable, cloud-based agents by utilizing a managed Codex harness. This architecture allows OpenAI to handle the complex underlying processes of session management, orchestration, context compaction, and recovery, while developers maintain control over the execution environment and the specific tools the agent can access. By offloading these backend responsibilities, developers can focus on creating agents that perform specialized tasks, such as investigating alerts, reviewing documents, or interacting with various software platforms.
At the heart of the system are four primary concepts: the agent, the environment, the session, and the events. The agent is defined by its specific model, instructions, tools, and any Model Context Protocol (MCP) servers it may require. The environment can either be an OpenAI-hosted sandbox or a self-hosted one, providing a secure space where the agent can run code, edit files, and utilize its capabilities. Sessions serve as durable instances where the agent maintains work over time, and events track the input and output produced throughout these interactions.
The managed harness provides a robust suite of features designed to enhance agent performance and reliability. It supports the execution of code in sandboxes, the application of various skills, and the ability to connect to external data sources. Furthermore, the API facilitates active management of the agent, including the ability to steer it during tasks, summarize past work to optimize the context window, and delegate complex objectives to subagents.
To get started, developers create a session, configure the agent's capabilities, and provide an initial task. Once the environment is ready, the agent begins processing, and developers can monitor progress via streaming or webhooks. Because the API maintains session state, agents can resume work seamlessly without the need to reconstruct the conversation history. While this setup provides significant power, developers should note that the Agents API currently requires data residency in the United States and does not support Zero Data Retention.
186 comments • Comments Link
• 开发定制的 Agent harness 非常复杂且耗时,但许多开发者仍倾向于自行构建,以保持控制权、避免供应商锁定(vendor lock-in),并根据具体需求定制工作流。
• 托管 agent API 通过抽象化的环境管理、安全补丁和可扩展性带来了便利,这种折中方案吸引了那些优先追求速度和免维护基础设施的团队。
• 像 OpenAI 和 Anthropic 这样的专有模型通常在核心推理能力上更胜一筹,但开发者越来越担心"黑盒"特性以及平台 API 的不稳定性,这些不稳定性可能使自定义实现迅速过时。
• 行业内存在两种对立倾向:一方面运行基于虚拟机(VM)的本地 agents,以实现对数据和运行环境的完全控制;另一方面采用以牺牲自主性换取集成便捷性的云端托管 managed agents 。
• 一个重要的顾虑是"信任"问题。许多开发者将托管服务视为潜在的数据泄露渠道,并担心个人计算长期被演变为昂贵且依赖云订阅的服务模式。
• Agent 的能力正在迅速演进,近期趋势强调对持久状态(persistent state)、沙箱隔离(sandbox isolation)以及将本地数据与远程编排相连接能力的需求。
• 部分开发者对不一致的配额消耗和"黑盒"性能表示沮丧,这推动了对自托管替代方案(self-hosted alternatives)的兴趣,这类方案允许在模型间切换并独立执行预算控制(budget enforcement)。
• 虽然大型企业可能从托管 agent 服务中受益,但个人开发者和小团队通常更青睐开源库或易于迁移的轻量级自托管 harnesses 。
• 安全仍是首要考量——即便是受限的沙箱环境,也可能被具有创造性利用能力的 agents 利用或被未授权修改配置,从而带来风险。
• 技术界普遍认为,Agent 的"正确"抽象仍在形成中,许多开发者倾向于采用定制化方案,将 LLM 视为模块化工具而非整套基础设施。
目前的讨论反映出托管 AI 生态的便利性与对架构主权(architectural sovereignty)的渴望之间存在根本性张力。尽管主要供应商提供了强大且有补贴的基础设施以简化 Agent 的部署,但这也带来了对供应商的依赖,并可能削弱对自身技术栈的控制。开发者正通过构建混合系统(hybrid systems)来应对这一矛盾,通常在利用 frontier models 进行推理与使用定制的、本地管理的 harnesses 或虚拟机之间取得平衡,以维护数据隐私和工作流一致性。总的来看,社区正在走向对"Agentic"系统的成熟认识——把它们视为需要精心编排的模块化工具,而非单一的整体服务;对于那些能避免沉重技术债务(load-bearing tech debt)并支持模型互操作(model interoperability)的方案,社区表现出明显偏好。 • Developing custom agent harnesses is a complex, time-consuming challenge, yet many developers prefer building their own to retain control, avoid vendor lock-in, and customize workflows to specific requirements.
• Managed agent APIs offer convenience by abstracting environment management, security patching, and scalability, providing a "middle ground" that appeals to teams prioritizing speed and maintenance-free infrastructure.
• Proprietary models like those from OpenAI and Anthropic are often seen as superior for core reasoning, though developers are increasingly wary of "black box" features and the volatility of platform APIs that risk rendering custom implementations obsolete.
• The industry is divided between running local, VM-based agents for full control over data and environment security, and adopting cloud-hosted managed agents that sacrifice autonomy for ease of integration.
• A significant concern involves the "trust" factor. Many developers view managed services as a potential vector for data exposure and worry about the long-term trend of personal computing becoming an expensive, cloud-dependent subscription service.
• Agent capabilities are evolving rapidly, with recent trends emphasizing the need for persistent state, sandbox isolation, and the ability to bridge local data with remote orchestration.
• Some developers express frustration with inconsistent quota consumption and "black box" performance, leading to a growing interest in self-hosted alternatives that allow for model switching and independent budget enforcement.
• While large companies may benefit from managed agent services, individual developers and smaller teams often find greater value in open-source libraries or lightweight, self-hosted harnesses that are easily migrated.
• Security remains a paramount concern, as even "restricted" sandbox environments face risks from agents capable of creative exploitation or unauthorized configuration changes.
• Technical consensus suggests that the "right" abstraction for agents is still being defined, with many developers settling on bespoke solutions that treat the LLM as a modular tool rather than the entire infrastructure.
The discourse reflects a fundamental tension between the convenience of managed AI ecosystems and the desire for architectural sovereignty. While major providers offer powerful, subsidized infrastructure that simplifies agent deployment, this comes at the cost of vendor dependency and potential erosion of control over one's own stack. Developers are currently navigating this by building hybrid systems—often balancing the use of frontier models for reasoning with custom-built, locally managed harnesses or VMs to maintain data privacy and workflow consistency. Ultimately, the community is moving toward a more mature understanding of "agentic" systems as modular tools that require careful orchestration rather than monolithic services, with a clear preference emerging for solutions that avoid "load-bearing tech debt" and permit model interoperability.