Mingyu's Library主页
深度学习 · 2026-09-11 Deep Dive · 2026-09-11

托管 Agent 运行时:OpenAI Agents API 深度解析

Managed Agent Runtime: A Deep Dive into the OpenAI Agents API

过去两年,每个做 agent 的团队都自己写过一遍「循环」——调模型、调工具、压上下文、派子任务、断线重连。2026 年 9 月 10 日,OpenAI 把驱动 Codex 的那套循环打包成了 API。这篇讲清楚:它到底托管了什么、怎么用、什么时候该用、什么时候不该。

For two years, every team building agents wrote the same loop by hand: call the model, call the tools, compact the context, fan out subtasks, recover from disconnects. On 10 September 2026, OpenAI packaged the loop behind Codex into an API. This piece covers what it actually manages, how to use it, when it fits, and when it doesn't.

调研时间:2026-09-11 · 状态:公测(public beta) · 主要依据官方文档与发布公告,第三方说法已单独标注

Researched: 2026-09-11 · Status: public beta · Based on official docs and the launch announcement; third-party claims are labelled as such

0130 秒速览

01In 30 Seconds

先给全貌,细节后面逐层展开。

The whole picture first; details come layer by layer.

Agents API 是 OpenAI 在 2026 年 9 月 10 日开放公测的一套托管 agent 运行服务。你用一次 API 调用创建一个「会话」(session),在里面指定任务、模型、工具和运行环境;OpenAI 负责把 agent 跑起来并让它一直跑下去——包括调用模型、执行工具循环、在上下文快满时自动压缩、把活拆给子 agent、以及在断线后保住进度。

The Agents API is a managed service for running agents, opened in public beta by OpenAI on 10 September 2026. You create a session in a single API call, specifying the task, model, tools, and environment; OpenAI runs the agent and keeps it running — calling the model, driving the tool loop, compacting context as it fills up, splitting work across subagents, and preserving progress across disconnects.

一句话:它把「agent 的运行时」外包了。你还是写工具、写提示词、决定工作流;但那圈围绕模型转的脏活——上下文管理、工具检索、子 agent 编排、会话持久化——由 OpenAI 托管并随模型升级同步演进。
In one line: it outsources the agent runtime. You still write the tools, the prompts, and the workflow; the grubby loop around the model — context management, tool retrieval, subagent orchestration, session durability — is hosted by OpenAI and upgraded alongside the models.
2026-09-10
公测开放日
$0 附加费
只按 token 与工具用量计费
3 种
运行环境模式
9 家
公布的沙箱生态伙伴
2026-09-10
Public beta opened
$0 extra
You pay only for tokens & tools
3
Environment modes
9
Announced sandbox partners

来源:Introducing the Agents API — OpenAI, 2026-09-10

Source: Introducing the Agents API — OpenAI, 10 Sep 2026

你的应用 提交任务 · 接收事件 处理 function tools Agents API 托管的 Codex harness 模型调用 · 工具循环 上下文压缩 · 会话持久 子 agent 编排 ← OpenAI 负责这一层 → 运行环境 跑命令 · 改文件 产出 artifacts 任务 事件 工具调用 结果 自托管环境时,环境的启停由你的应用控制

图 1:三方关系。你的应用提交任务、收事件;OpenAI 托管的 harness 跑循环;环境负责真正执行命令。依据官方架构文档绘制。

Your app submits tasks · gets events handles function tools Agents API managed Codex harness model calls · tool loop compaction · durable sessions subagent orchestration ← OpenAI owns this layer → Environment runs commands · edits files produces artifacts tasks events tool calls results With a self-hosted environment, your app controls its lifecycle

Fig. 1: The three parties. Your app submits tasks and receives events; OpenAI's managed harness runs the loop; the environment actually executes. Drawn from the official architecture guide.

02它在解决什么痛

02The Pain It Solves

先讲问题,再讲答案——否则你很难判断这个答案值不值。

Problem first, answer second — otherwise you can't judge whether the answer is worth it.

要理解这个 API,得先明白一个词:harness

To understand this API, you first need one word: harness.

harness(运行骨架)
模型本身只会「给一段输入、吐一段输出」。要让它变成能连续干几小时活的 agent,你得在外面套一圈代码:把用户的任务发给模型、看它想调什么工具、真的去调、把结果塞回去、再问模型下一步……这圈代码就叫 harness。中文里没有特别好的对应词,可以理解成「让模型动起来的那套传动装置」。
官方定义:OpenAI 托管的 Codex 实例,负责运行模型与工具循环,并维护 agent 的会话。
harness
A model on its own only does "text in, text out". To turn it into an agent that works for hours, you wrap code around it: send the task to the model, see which tool it wants, actually call it, feed the result back, ask again. That wrapper is the harness — the drivetrain that turns model output into sustained work.
Official definition: the OpenAI-hosted Codex instance that runs the model and tool loop and maintains the agent's session.

写一个「能跑通 demo」的 harness 是一个下午的事。让它在生产环境跑几小时几天不出事,是另一回事。真正吃掉时间的是这几样:

Writing a harness that survives a demo takes an afternoon. Making one that runs for hours or days in production is a different job. The time goes into these:

类比:模型像一台发动机,harness 是变速箱、离合和传动轴。过去每家买了发动机都得自己造一套传动系统,还得在发动机换代时重造一遍。Agents API 相当于厂家说:传动系统我们一起给你,而且每次换发动机我们同步调好。代价是——这套传动系统的内部你不再自己决定。
Analogy: the model is an engine; the harness is the gearbox, clutch and driveshaft. Until now everyone who bought an engine also built their own transmission — and rebuilt it at every engine generation. The Agents API is the manufacturer saying: we'll ship the transmission too, tuned for each new engine. The price is that you no longer decide what's inside it.

来源:OpenAI 发布公告 · Agents API Architecture 文档

Sources: OpenAI launch post · Agents API architecture guide

03三块积木:harness、environment、application server

03Three Building Blocks: Harness, Environment, Application Server

官方架构文档把整个系统拆成三块。搞清这三块,后面所有配置都有地方安放。

The official architecture guide splits the system into three parts. Once these click, every config option has a place to live.

Harness(OpenAI 托管)
跑模型与工具循环、维护会话的那个 Codex 实例。你不部署它、不运维它,也不直接改它的内部逻辑。
Environment(可选,位置你定)
agent 跑命令、执行代码、读写文件的地方。官方明确列出它可以是:远程沙箱、你的笔记本、一个 Docker 容器,甚至一个 AWS Lambda 函数。
Application server(你写)
把 agent 接进你产品的那段代码:提交任务、接收事件、处理 function tools。如果环境是你自己提供的,它还要负责环境的生命周期。
Harness (hosted by OpenAI)
The Codex instance that runs the model and tool loop and maintains the session. You don't deploy it, operate it, or edit its internals.
Environment (optional; you choose where)
Where the agent runs commands, executes code, and works with files. The docs spell out the options: a remote sandbox, your laptop, a Docker container, or an AWS Lambda function.
Application server (you write it)
The code that connects the agent to your product: submits tasks, receives events, handles function tools. If you supply the environment, it also manages that environment's lifecycle.
一个容易漏掉的设计要点:官方说「从你的任务需要的那几块开始」——harness 可以完全不带环境运行。一个只回答问题、只调外部服务的 agent,根本不需要自己的计算和文件系统。
An easy point to miss: the docs say "start with the pieces your task needs" — the harness can run with no environment at all. An agent that answers questions or calls external services doesn't need its own compute or filesystem.

收结果的两种方式

Two ways to receive results

无论选哪种环境,拿进度和结果都有两条路,可以同时用:streaming(开着流,实时拿到细粒度事件,适合在产品里显示 agent 正在做什么)和 webhooks(不用一直挂着连接,会话状态变化时回调你的 handler;handler 里可以取结果、跑 function tool、管自托管环境)。

Whichever environment you pick, there are two ways to get progress — and you can use both: streaming (keep a stream open for fine-grained events, good for showing users what the agent is doing) and webhooks (no long-lived connection; your handler is called on session state changes and can fetch results, run function tools, or manage a self-hosted environment).

官方警告:function tool 需要一个能接住调用并返回结果的 handler。如果那个 handler 不可用,agent 会一直等下去。事件处理或生命周期 handler 出错,同样会中断进度更新或环境管理。
Official warning: function tools need a handler that receives calls and returns results. If that handler is unavailable, the agent can remain waiting. Failures in your event or lifecycle handlers can likewise interrupt progress updates or environment management.

来源:Architecture — OpenAI API Docs

Source: Architecture — OpenAI API Docs

04上手:第一个会话

04Your First Session

以下代码取自官方 quickstart,未做改写。

The code below is taken from the official quickstart, unmodified.

  1. 准备 API key。在 OpenAI Platform 项目里创建 application API key,授予 api.agents.readapi.agents.write(会话操作)以及 api.responses.write(模型推理)。官方特别提醒:把这个 key 放在 agent 沙箱之外
  2. 带上 beta header。请求需要 OpenAI-Beta: agents=v1。官方 SDK 会自动加,用 cURL 时要自己写。
  3. 创建会话并提交任务。SDK 里走 beta.agents 命名空间,一次调用同时完成「建会话 + 提交任务 + 开流」。
  4. 跟进度。盯事件流,看到 agent.session.turn.completed 再检查 agent 报告的执行结果。
  5. 继续或清理。存下 session_id 发后续任务,或者在保存好需要的文件后删除会话。
  1. Get an API key. Create an application API key in your OpenAI Platform project with api.agents.read and api.agents.write (session operations) plus api.responses.write (model inference). The docs add a pointed reminder: keep this key outside the agent's sandbox.
  2. Send the beta header. Requests need OpenAI-Beta: agents=v1. The official SDKs add it; with cURL you supply it yourself.
  3. Create a session and submit the task. In the SDKs this lives under the beta.agents namespace; one call creates the session, submits the task, and opens the stream.
  4. Follow progress. Watch the event stream; once you see agent.session.turn.completed, check the execution result the agent reports.
  5. Continue or clean up. Save the session_id for follow-ups, or delete the session after saving any files you need.

最小可运行例子(Python,官方 quickstart 原样):

Minimal runnable example (Python, verbatim from the official quickstart):

# pip install --upgrade openai
from openai import OpenAI

with OpenAI() as client:
    with client.beta.agents.sessions.create(
        agent={
            "model": "gpt-6-astra",
            "instructions": "Write clean code, run it, and report the actual output.",
        },
        environment={"type": "openai_hosted"},
        input="Create tree.py, a Python script that prints a readable tree of the files in the current directory. Run it and show me the output.",
        stream=True,
    ) as events:
        for event in events:
            print(event.to_json(indent=None), flush=True)
# pip install --upgrade openai
from openai import OpenAI

with OpenAI() as client:
    with client.beta.agents.sessions.create(
        agent={
            "model": "gpt-6-astra",
            "instructions": "Write clean code, run it, and report the actual output.",
        },
        environment={"type": "openai_hosted"},
        input="Create tree.py, a Python script that prints a readable tree of the files in the current directory. Run it and show me the output.",
        stream=True,
    ) as events:
        for event in events:
            print(event.to_json(indent=None), flush=True)

发布公告里给的那个例子更能说明「生产级 agent 一次调用建好」是什么意思——注意 tools 里直接挂了一个远程 MCP server,multi_agent 开了三个并发子 agent,vault_ids 传了密钥保管库,capability_directories 指向沙箱里的 skills 目录:

The example in the launch post shows better what "a production-ready agent in a single call" means — note the remote MCP server wired straight into tools, three concurrent subagents via multi_agent, a secrets vault through vault_ids, and capability_directories pointing at a skills folder inside the sandbox:

const session = await client.beta.agents.sessions.create({
  agent: {
    model: "gpt-6-astra",
    tools: [{
      type: "mcp",
      server_label: "observability",
      transport: { type: "http", server_url: "https://observability.example.com/mcp" },
    }],
    multi_agent: { enabled: true, max_concurrent_subagents: 3 },
  },
  vault_ids: ["vault_YOUR_VAULT_ID"],
  environment: {
    type: "openai_hosted",
    capability_directories: ["/workspace/capabilities/skills"],
  },
  input:
    "Investigate service-api's elevated 5xx rate over the last 30 minutes. " +
    "Delegate deployment, error, and dependency analysis to subagents. " +
    "Save findings, evidence, and recommended mitigation in /workspace/outputs.",
});
const session = await client.beta.agents.sessions.create({
  agent: {
    model: "gpt-6-astra",
    tools: [{
      type: "mcp",
      server_label: "observability",
      transport: { type: "http", server_url: "https://observability.example.com/mcp" },
    }],
    multi_agent: { enabled: true, max_concurrent_subagents: 3 },
  },
  vault_ids: ["vault_YOUR_VAULT_ID"],
  environment: {
    type: "openai_hosted",
    capability_directories: ["/workspace/capabilities/skills"],
  },
  input:
    "Investigate service-api's elevated 5xx rate over the last 30 minutes. " +
    "Delegate deployment, error, and dependency analysis to subagents. " +
    "Save findings, evidence, and recommended mitigation in /workspace/outputs.",
});
最重要的一条官方提醒,请读两遍:一个 turn 完成,不代表每个工具都成功了。」以 turn.failedturn.cancelledsession.failed 结尾的事件表示失败或取消;而 agent.session.idle 单独出现并不意味着成功。如果流提前断开,先取回会话及其已保存的 items,再决定是否重试。
The single most important official caveat — read it twice: "A completed turn does not guarantee every tool succeeded." Events ending in turn.failed, turn.cancelled, or session.failed mean failure or cancellation; agent.session.idle on its own does not mean success. If the stream disconnects early, retrieve the session and its saved items before retrying.
换个说法:为什么「turn 完成 ≠ 成功」这么要命?

因为大多数人写重试逻辑时,判断条件就是「这一轮结束了吗」。如果你只看 turn 完成就返回成功,那么一个「跑了脚本、脚本报错、agent 如实汇报了错误、然后正常结束这一轮」的过程,在你的系统里会被记成一次成功交付。错误会静悄悄地流到下游。正确做法是:既看事件类型,也读 agent 报告的执行结果。

Put differently: why is "turn completed ≠ success" so dangerous?

Because most retry logic keys off "did this turn end?". If you treat a completed turn as success, then a run where the script failed, the agent faithfully reported the error, and the turn ended normally gets recorded as a successful delivery. The failure flows silently downstream. The fix: check the event type and read the execution result the agent reports.

来源:Agents API quickstart · 发布公告

Sources: Agents API quickstart · launch post

05harness 自带的四件事

05Four Things the Harness Does for You

这四件,正是过去每个团队自己重写一遍的部分。

These four are exactly what every team used to reimplement.

① 自动 compaction:让会话活过上下文窗口

① Automatic compaction: surviving the context window

会话逼近上下文上限时,Agents API 会自动压缩较早的上下文,保留 agent 继续干活所需的信息。官方给的意义是:开发者可以写「跨多个上下文窗口」的工作流,而不必自己实现压缩逻辑。

As a session approaches its context limit, the Agents API automatically compacts earlier context, preserving what the agent needs to continue. The stated upshot: you can build workflows that span multiple context windows without implementing your own compaction logic.

② tool search:工具多了也不烧 token

② Tool search: many tools without the token bill

tool search 按需加载相关的工具定义,而不是把所有工具一次性塞进上下文。官方说明这样做有两个好处:降低 token 用量与成本,以及保住模型的缓存——后者常被忽略,但它才是大头:工具列表是 prompt 前缀里最靠前的一段,一动就让整个缓存前缀失效。

Tool search loads relevant tool definitions as needed rather than dumping every tool into context. The docs cite two benefits: lower token usage and cost, and preserving the model's cache — the second matters more than people expect, since the tool list sits near the front of the prompt prefix, and touching it invalidates the whole cached prefix.

③ programmatic tool calling:在代码里处理工具结果

③ Programmatic tool calling: handle tool results in code

工具可用之后,programmatic tool calling 让 agent 并行发起调用、串联相关操作、并在代码里过滤或合并结果,从而处理大批量数据,而只把相关的那部分带回上下文

Once tools are available, programmatic tool calling lets the agent run calls in parallel, chain related operations, and filter or combine results in code, so it can work through large volumes of data while bringing only the relevant results back into context.

④ subagents:把活拆开并行做

④ Subagents: split the work and run it in parallel

开启多 agent 支持后,Agents API 可以把复杂任务拆成互相独立的几块,交给并行工作的子 agent。关键设计:每个子 agent 维护自己的上下文,以便专注于自己那一份;主 agent 负责协调并汇总结果。配置极简:

With multi-agent support enabled, the Agents API can break a complex task into independent pieces and delegate them to subagents working in parallel. The key design point: each subagent keeps its own context so it stays focused on its assignment, while the main agent coordinates and merges results. The config is minimal:

"agent": {
  "model": "gpt-6-astra",
  "multi_agent": {
    "enabled": true,
    "max_concurrent_subagents": 3
  }
}
"agent": {
  "model": "gpt-6-astra",
  "multi_agent": {
    "enabled": true,
    "max_concurrent_subagents": 3
  }
}
三种机制,一个目标:让进入模型的上下文保持「小而相关」 compaction 管的是「时间轴」 早期对话 → 被压缩 会话快满时自动触发 保留继续干活所需信息 tool search 管的是「工具清单」 只加载当前相关的定义 省 token,且保住缓存前缀 配套:programmatic tool calling 在代码里并行、过滤、合并 subagents 管的是「谁的上下文」 主 agent 每个子 agent 独立上下文 主 agent 协调并汇总 时间轴上压缩、工具清单上筛选、任务维度上分流——三条互补的路径

图 2:compaction 管时间轴、tool search 管工具清单、subagents 管任务分流。三者共同把进入模型的上下文压小。依据官方文档整理。

Three mechanisms, one goal: keep what reaches the model small and relevant compaction acts on the timeline early turns → compacted triggers near the context limit keeps what's needed to continue tool search acts on the tool list loads only what's relevant now saves tokens, preserves the cache paired with: programmatic tool calling parallelise, filter, combine in code subagents acts on whose context it is main each subagent keeps its own context the main agent coordinates Compress the timeline, filter the tool list, fan out the task — three complementary paths

Fig. 2: compaction works on the timeline, tool search on the tool list, subagents on task fan-out. Together they keep the model's context small. Compiled from the official docs.

还有一条不在功能列表里、但可能最值钱:官方承诺随每次模型发布提供版本化的 harness 能力,并与模型同步维护和改进,让 agent「从每次升级里都拿到更好的表现」。也就是说,你买的不只是今天这套循环,还有它跟上模型迭代的义务。
One more, not in the feature list but possibly the most valuable: OpenAI commits to versioned access to harness capabilities with each model launch, maintained and improved alongside the models so agents "get better performance from every upgrade". You're buying not just today's loop, but the obligation to keep it current.

来源:Compaction · Tool search · Programmatic tool calling · Multi-agent

Sources: Compaction · Tool search · Programmatic tool calling · Multi-agent

06环境选型:none / openai_hosted / self_hosted

06Choosing an Environment: none / openai_hosted / self_hosted

这是接入时第一个要拍板的决定,也是责任边界最不一样的地方。

This is the first decision you'll make, and the one where responsibility shifts most.

agent 需要自己的计算吗? type: "none" 只答问题 / 只调外部服务 harness 可直接调远程 MCP ✕ 无内建 Bash / apply-patch ✕ 无工作区文件 / executor MCP "openai_hosted" OpenAI 建并管沙箱 可配包 / 文件 / 网络 可装 skills 与 plugins 最快上手 "self_hosted" 你的基建 / 内网 / 专用软件 你起环境并接上 executor 你负责:开通 · 重连 · 关停 你负责:需要保留的文件 自托管前务必确认:关停算力之前,没有待执行的调用

图 3:三种环境模式与各自的责任边界。越往右,能力越大、你要管的事越多。依据官方架构文档绘制。

Does the agent need compute? type: "none" answers questions / calls services harness calls remote MCP directly ✕ no built-in Bash / apply-patch ✕ no workspace files / executor MCPs "openai_hosted" OpenAI creates & manages it configure packages / files / network skills and plugins supported fastest to start "self_hosted" your infra / private network / software you start it and attach an executor you own: provisioning · reconnect · shutdown you own: any files to preserve Before stopping compute, confirm no execution is pending

Fig. 3: the three environment modes and where responsibility sits. Further right means more capability and more to operate. Drawn from the official architecture guide.

模式什么时候选你要负责什么注意
noneagent 只回答问题、或只通过工具访问外部服务,不需要自己的计算和文件function tool 的 handler内建 Bash 与 apply-patch 工具、工作区文件、executor MCP 全部不可用
openai_hostedagent 需要跑脚本、改文件、产出 artifacts,又想快速起步并弹性扩展提交任务、收事件、处理 function tool用的是与 Codex / ChatGPT 相同的沙箱基础设施;可配置文件、包、skills 与 plugins
self_hostedagent 需要你的基础设施、内网,或自定义软件启动环境并接上 executor;开通、重连、关停;需要保留的文件关停算力前必须协调好待进入的工作,并确认没有执行中的调用
ModeWhen to pick itWhat you ownWatch out
noneThe agent only answers questions or reaches external services through tools; no compute or files of its ownHandlers for your function toolsBuilt-in Bash and apply-patch tools, workspace files, and executor MCPs are all unavailable
openai_hostedThe agent runs scripts, edits files, produces artifacts — and you want to start fast and scaleSubmitting tasks, receiving events, handling function toolsSame sandbox infrastructure that powers Codex and ChatGPT; configurable files, packages, skills and plugins
self_hostedThe agent needs your infrastructure, private network, or custom softwareStarting the environment and attaching an executor; provisioning, reconnection, shutdown; any files to preserveBefore stopping compute, coordinate incoming work and confirm no execution is pending

自托管不必从零搭。OpenAI 同时公布了沙箱生态合作方,提供一等公民集成:Blaxel、Cloudflare、Daytona、DigitalOcean、E2B、Modal、Oracle、Runloop、Vercel。官方列出的差异化维度是:全托管环境 vs 部署进你自己的 VPC;不同的文件与密钥存储机制;不同的 CPU / GPU / 内存配置,以及各自的性能、冷启动与成本曲线。

Self-hosting doesn't mean building from scratch. OpenAI also named sandbox ecosystem partners with first-class integrations: Blaxel, Cloudflare, Daytona, DigitalOcean, E2B, Modal, Oracle, Runloop, Vercel. The dimensions they differ on, per the announcement: fully managed environments versus deployment inside your own VPC; different file and secret storage mechanisms; different CPU, GPU and memory configurations with their own performance, cold-start and cost profiles.

来源:Architecture · OpenAI-hosted sandboxes · Self-hosted sandboxes

Sources: Architecture · OpenAI-hosted sandboxes · Self-hosted sandboxes

07和谁比、怎么选

07Alternatives and How to Choose

以下按各方公开定位对比,非逐项实测;选型请以自己的工作负载实测为准。

Compared on publicly stated positioning, not head-to-head benchmarks; validate against your own workload before committing.

方案它的主张适合代价
自己写 harness完全控制循环逻辑有特殊的编排需求;必须离线或完全自主可控;把 harness 本身当作差异化能力上下文管理、工具检索、并行编排、断线恢复全部自己实现并持续维护;模型换代要重写
OpenAI Agents API托管 Codex harness,随模型版本化演进长时运行、多工具、需要沙箱与子 agent 的生产 agent;不想把工程预算花在循环上绑定 OpenAI 模型与运行时;harness 内部由 OpenAI 决定(底座开源可读,但你不运维);公测期 API 会变
Claude Agent SDK把 Claude Code 的 agent 能力以 SDK 形式提供,在你自己的进程里跑已在 Anthropic 生态;希望 agent 跑在自己的机器/网络里并完全掌控进程运行时归你运维;跨厂商迁移成本仍在
LangGraph把工作流建模成节点与边的图,提供持久状态、人类介入检查点、分支与循环需要显式控制流、人审节点、失败重试与恢复语义的工作流图要自己设计和维护;上下文压缩、工具检索等仍多为自建或选装
OptionIts claimGood fit whenWhat it costs you
Roll your own harnessTotal control over the loopYou have unusual orchestration needs, must run offline or fully self-governed, or treat the harness itself as differentiationYou implement and maintain context management, tool retrieval, parallel orchestration and recovery — and rework it at every model generation
OpenAI Agents APIA managed Codex harness, versioned alongside the modelsLong-running, many-tool production agents needing sandboxes and subagents, where engineering budget shouldn't go into the loopCoupling to OpenAI models and runtime; harness internals decided by OpenAI (the base is open source to read, but you don't operate it); the API will change during beta
Claude Agent SDKClaude Code's agent capabilities as an SDK, running inside your own processYou're already in Anthropic's ecosystem and want the agent on your machines and network, fully under your controlThe runtime is yours to operate; cross-vendor migration cost remains
LangGraphWorkflows as graphs of nodes and edges, with durable state, human-in-the-loop checkpoints, branching and cyclesWorkflows needing explicit control flow, approval steps, and well-defined retry/resume semanticsYou design and maintain the graph; compaction, tool retrieval and similar remain build-or-bolt-on
一句判断规则:如果你的 agent 的价值来自「它接了哪些工具、懂哪些领域知识、跑什么工作流」,那 harness 是成本项,托管掉是划算的;如果价值恰恰来自「循环怎么转」——比如你在做 agent 平台本身、或有硬性的自主可控要求——那就不该托管。
One rule of thumb: if your agent's value comes from which tools it has, what domain knowledge it carries, and what workflow it runs, then the harness is a cost centre and outsourcing it pays. If the value is how the loop turns — you're building an agent platform, or you have hard sovereignty requirements — don't outsource it.

厂商公布的效果数据(请按营销材料对待)

Vendor-published results (treat as marketing material)

发布页上有八条客户证言,其中带数字的几条:SafetyKit 称把案件审查工作流迁过来后「每案成本下降 60%、延迟下降、token 效率显著提升,性能维持不变」;Hypha 称「把 agent harness 与 sandbox 分离后,失败的 agent 响应减少了 86%」;Ciridae 称评测分从 0.71 升到 0.85,并称子 agent 流带来「4 倍延迟下降」。这些均为客户自述、无独立验证,也没有公开方法论。截至调研时,我们没有检索到第三方对 Agents API 的独立评测。

The launch page carries eight customer testimonials; the ones with numbers: SafetyKit reports "a 60% reduction in cost per case, lower latency, and significantly improved token efficiency while maintaining existing performance" after migrating its case-review workflow; Hypha reports "reduced failed agent responses by 86%" by separating the harness from the sandbox; Ciridae reports an evaluation score moving from 0.71 to 0.85 and "a 4x latency reduction" from subagent flows. All are self-reported, unverified, and published without methodology. As of this research date we found no independent third-party evaluation of the Agents API.

来源:OpenAI 发布公告(客户证言) · LangGraph 定位据 LangChain 官方框架介绍页

Sources: OpenAI launch post (testimonials) · LangGraph positioning per LangChain's own framework overview

08坑与限制

08Pitfalls and Limits

分两类:官方明说的,和我们基于公开信息的判断(已标注)。

Two kinds: what the docs say outright, and our reading of the public information (labelled as such).

官方明说的

Stated in the official docs

① turn 完成不等于成功。必须同时看事件类型和 agent 报告的执行结果,别把 agent.session.idle 当成功信号。
② function tool handler 挂了,agent 会一直等。事件与生命周期 handler 的失败也会中断进度更新和环境管理。
③ 自托管环境的关停要小心。停算力之前必须协调好待进入的工作,并确认没有执行中的调用;重连、开通、文件保留全归你。
④ API key 不要放进沙箱。quickstart 里专门点了这句。
⑤ 无环境模式下能力有明确缺口。内建 Bash、apply-patch、工作区文件、executor MCP 全不可用。
⑥ 这是公测。官方原话是会「根据反馈快速迭代,直至正式可用」——即接口会变。
① A completed turn is not success. Check the event type and the execution result; never read agent.session.idle as a success signal.
② If a function tool handler is down, the agent waits. Failures in event or lifecycle handlers likewise interrupt progress updates and environment management.
③ Shutting down a self-hosted environment is delicate. Coordinate incoming work and confirm nothing is executing before stopping compute; reconnection, provisioning and file preservation are yours.
④ Keep the API key out of the sandbox. The quickstart calls this out explicitly.
⑤ The no-environment mode has real gaps. Built-in Bash, apply-patch, workspace files and executor MCPs are all unavailable.
⑥ This is a public beta. OpenAI says it will "iterate quickly based on your feedback as we work toward general availability" — meaning the surface will change.

我们的判断(非官方,供参考)

Our reading (not official)

诚实的空白:截至 2026-09-11,该 API 上线仅一天,我们没有找到独立的生产实践报告、第三方基准测试或社区踩坑汇总。本节的「官方明说」部分可信度高,「我们的判断」部分请当作假设去验证,而不是结论。
An honest gap: as of 11 Sep 2026 the API is one day old. We found no independent production reports, third-party benchmarks, or community post-mortems. The "stated in the docs" items are solid; treat "our reading" as hypotheses to test, not conclusions.

09术语表与资源

09Glossary and Resources

session(会话)
一次 agent 工作的持久单元。跨多轮继续、可流式跟进、可被取回。存下 session_id 就能发后续任务。
turn(一轮)
会话里的一次「提交输入 → agent 干活 → 收敛」的过程。完成事件是 agent.session.turn.completed
executor(执行器)
自托管模式下由你启动并接入会话的那一端,负责真正执行 harness 请求的命令与工具。
MCP(Model Context Protocol)
一套让 agent 连接外部工具与数据源的开放协议。harness 可以直接调用远程 MCP server。
function tool
由你的代码实现的工具:harness 把调用发给你,你执行后把结果返回。与远程 MCP 工具的区别就在这——谁来执行。
artifact(产物)
agent 在环境里产出的文件成果。删会话之前记得先保存。
session
The durable unit of agent work. Continues across turns, can be streamed, and can be retrieved. Keep the session_id to send follow-ups.
turn
One cycle of "submit input → agent works → settles" inside a session. Its completion event is agent.session.turn.completed.
executor
In self-hosted mode, the endpoint you start and connect to the session; it actually runs the commands and tools the harness requests.
MCP (Model Context Protocol)
An open protocol for connecting agents to external tools and data sources. The harness can call remote MCP servers directly.
function tool
A tool implemented by your code: the harness sends you the call, you run it and return the result. That's the difference from a remote MCP tool — who executes.
artifact
Files the agent produces inside the environment. Save what you need before deleting the session.

继续深入

Go deeper