OpenAI 发布 Codex:基于 o3 的云原生软件工程智能体

原标题:Introducing Codex
88AI 研判分

OpenAI 推出研究预览版 Codex,这是一个能并行处理多项任务的云端软件工程智能体。它由针对编程优化的 codex-1(o3 变体)驱动,通过强化学习在真实代码环境中训练,具备自动运行测试、修复 Bug 及生成 PR 的能力,并支持沙箱隔离执行。

报道正文

本文目录11 个章节

2025 年 6 月 3 日更新:Codex 现已向 ChatGPT Plus 用户开放。我们同时允许用户在任务执行期间为 Codex 提供互联网访问权限。详情请参阅 changelog⁠(opens in a new window)和 docs⁠(opens in a new window)。


今天,我们推出了 Codex 的研究预览版:这是一个基于云的软件工程智能体(agent),能够并行处理多项任务。Codex 可以为你执行诸如编写功能、回答关于代码库的问题、修复 bug 以及提交 pull request 以供审查等任务;每个任务都在其独立的云沙箱环境中运行,并预加载了你的代码仓库。

Codex 由 codex-1 驱动,这是针对软件工程优化的 OpenAI o3 版本。它通过在多种环境中的真实编码任务上进行强化学习训练而成,生成的代码紧密贴合人类风格与 PR 偏好,严格遵循指令,并能迭代运行测试直至通过。我们今天开始向 ChatGPT Pro、Enterprise 和 Business 用户推出 Codex,Plus 和 Edu 用户的支持即将上线。

Codex 的工作原理

目前,你可以通过 ChatGPT 侧边栏访问 Codex,输入提示词并点击 “Code” 来分配新的编码任务。如果你想就代码库向 Codex 提问,请点击 “Ask”。每个任务都在一个独立的、隔离的环境中单独处理,该环境已预加载你的代码库。Codex 可以读取和编辑文件,也可以运行命令,包括测试框架、linter 和类型检查器。根据复杂程度不同,任务完成通常需要 1 到 30 分钟,你可以实时监控 Codex 的进度。

一旦 Codex 完成任务,它会在其环境中提交更改。Codex 通过引用终端日志和测试输出,为其操作提供可验证的证据,使你能够追溯任务完成过程中采取的每一步。随后,你可以审查结果、请求进一步修改、在 GitHub 上开启 pull request,或直接将更改集成到你的本地环境中。在产品中,你可以配置 Codex 环境,使其尽可能贴近真实的开发环境。

Codex 可以通过放置在代码仓库中的 AGENTS.md 文件进行引导。这些是文本文件,类似于 README.md,你可以在其中告知 Codex 如何导航你的代码库、运行哪些命令进行测试,以及如何更好地遵循项目的标准实践。与人类开发者一样,当提供配置好的开发环境、可靠的测试设置和清晰的文档时,Codex 智能体的表现最佳。

在编码评估和内部基准测试中,即使没有 AGENTS.md 文件或自定义脚手架,codex-1 也表现出强劲的性能。

有 23 个在我们的内部基础设施上无法运行的 SWE-Bench Verified 样本被排除在外。codex-1 在最大上下文长度为 192k tokens 和中等“推理努力”(reasoning effort)的设置下进行了测试,这也是今天产品中可用的设置。有关 o3 评估的详细信息,请参见此处⁠。 我们的内部 SWE 任务基准测试是一组精心挑选的 OpenAI 内部真实世界 SWE 任务。

构建安全且值得信赖的智能体

我们按照迭代部署策略,将 Codex 作为研究预览版发布。在设计 Codex 时,我们将安全性和透明度置于优先地位,以便用户可以验证其输出——随着 AI 模型独立处理更复杂的编码任务以及安全考量不断演变,这一保障措施变得愈发重要。用户可以通过引用来源、终端日志和测试结果来检查 Codex 的工作。当遇到不确定情况或测试失败时,Codex 智能体会明确沟通这些问题,使用户能够做出明智的决定以继续推进。然而,用户在集成和执行之前,仍然必须手动审查并验证所有由智能体生成的代码。

Image 1: Code-review screenshot with a test-file overlay verifying quoted filenames, plus summary and passing tests on a blue backdrop.

Image 2: Code-review screenshot with a black terminal overlay showing one passing test for quoted filenames; summary and diff of the ‘Fix /diff error with special characters’ change visible on a blue-pastel background.

对齐人类偏好

训练 codex-1 的首要目标之一,是使其输出紧密契合人类的编码偏好与标准。相较于 OpenAI o3,codex-1 始终能生成更整洁的代码补丁(patches),可直接供人工审查并集成至标准工作流中。

防止滥用

防范 AI 驱动的软件工程被用于恶意目的(例如开发恶意软件)正变得日益关键。与此同时,保护措施不应过度阻碍那些合法且有益的应用场景——尽管这些场景可能涉及某些同样被用于恶意软件开发的技术,例如底层内核工程。

为了在安全性与实用性之间取得平衡,Codex 经过训练能够识别并精准拒绝旨在开发恶意软件的请求,同时清晰区分并支持合法任务。我们还强化了政策框架,并纳入了严格的安全评估以有效巩固这些边界。我们已发布 o3 System Card 的附录⁠ 以反映上述评估结果。

安全执行

Codex agent 完全运行于云端一个安全隔离的容器中。在执行任务期间,互联网访问被禁用,从而将 agent 的交互范围限制为仅通过 GitHub 仓库明确提供的代码,以及用户通过 setup script 配置的预装依赖项。该 agent 无法访问外部网站、API 或其他服务。注意: 此处描述的是初始配置。关于当前 setup-phase 和 agent-phase 的网络选项,请参阅 Agent internet access⁠(opens in a new window)。

早期用例

OpenAI 的技术团队已开始将 Codex 纳入日常工具集。OpenAI 工程师最常使用它来分担那些重复性强、范围明确的琐碎任务,如重构、重命名和编写测试,以免打断专注状态。它在搭建新功能脚手架、连接组件、修复 bug 以及起草文档方面同样有用。团队正在围绕它建立新习惯:分诊值班问题、在一天开始时规划任务,并将后台工作外包以保持推进节奏。通过减少上下文切换并浮现被遗忘的待办事项,Codex 帮助工程师更快交付成果,并专注于最重要的事情。

在正式发布之前,我们还与一小部分外部测试人员合作,以更好地了解 Codex 在多样化的代码库、开发流程和团队中的表现。

  • Cisco⁠(opens in a new window) 正在探索 Codex 如何帮助其工程团队更快地将雄心勃勃的想法变为现实。作为早期设计合作伙伴,Cisco 通过在其产品组合中针对真实用例评估 Codex 并向 OpenAI 团队提供反馈,助力塑造 Codex 的未来。

  • Temporal⁠(opens in a new window) 使用 Codex 来加速功能开发、调试问题、编写和执行测试以及重构大型代码库。它还能通过在后台运行复杂任务来帮助团队保持专注——让工程师保持心流状态的同时加快迭代速度。

  • Superhuman⁠(opens in a new window) 使用 Codex 来加速那些虽小但重复性高的任务,例如提高测试覆盖率和修复集成失败问题。它还通过使产品经理能够在无需拉入工程师的情况下贡献轻量级代码更改(除代码审查外),从而帮助他们更快地发布产品。

  • Kodiak⁠(opens in a new window) 正在使用 Codex 来协助编写调试工具、提高测试覆盖率并重构代码——从而加速其自动驾驶技术 Kodiak Driver 的开发。Codex 还已成为一个宝贵的参考工具,通过呈现相关上下文和过往变更,帮助工程师理解技术栈中不熟悉的部分。

基于早期测试人员的经验,我们建议同时将范围明确的任务分配给多个智能体,并尝试不同类型的任务和提示词,以有效地探索模型的能力。

Codex CLI 更新

上个月,我们推出了 Codex CLI,这是一款在终端中运行的轻量级开源编码智能体。它将 o3 和 o4-mini 等模型的强大能力带入你的本地工作流,让你能够轻松地与它们配对协作,以更快地完成任务。

[注:本文篇幅超长,以上为核心前篇精译,后续内容保留原文呈现]

Today, we’re also releasing a smaller version of codex-1, a version of o4-mini designed specifically for use in Codex CLI. This new model supports faster workflows in the CLI and is optimized for low-latency code Q&A and editing, while retaining the same strengths in instruction following and style. It’s available now as the default model in Codex CLI and in the API as codex-mini-latest. The underlying snapshot will be regularly updated as we continue to improve the Codex-mini model.

We’re also making it much easier to connect your developer account to Codex CLI. Instead of manually generating and configuring an API token, you can now sign in with your ChatGPT account and select the API organization you want to use. We’ll automatically generate and configure the API key for you. Plus and Pro users who sign in to Codex CLI with ChatGPT can also begin redeeming $5 and $50 in free API credits, respectively, later today for the next 30 days.

Codex availability, pricing, and limitations

Starting today, we’re rolling out Codex to ChatGPT Pro, Enterprise, and Business users globally, with support for Plus and Edu coming soon. Users will have generous access at no additional cost for the coming weeks so you can explore what Codex can do, after which we’ll roll out rate-limited access and flexible pricing options that let you purchase additional usage on-demand. We plan to expand access to Plus and Edu users soon.

For developers building with codex-mini-latest, the model is available on the Responses API and priced at $1.50 per 1M input tokens and $6 per 1M output tokens, with a 75% prompt caching discount.

Codex is still early in its development. As a research preview, it currently lacks features like image inputs for frontend work, and the ability to course-correct the agent while it’s working. Additionally, delegating to a remote agent takes longer than interactive editing, which can take some getting used to. Over time, interacting with Codex agents will increasingly resemble asynchronous collaboration with colleagues. As model capabilities advance, we anticipate agents handling more complex tasks over extended periods.

What’s next

We imagine a future where developers drive the work they want to own and delegate the rest to agents—moving faster and being more productive with AI. To achieve that, we’re building a suite of Codex tools that support both real-time collaboration and asynchronous delegation.

Pairing with AI tools like Codex CLI and others has quickly become an industry norm, helping developers move faster as they code. But we believe the asynchronous, multi-agent workflow introduced by Codex in ChatGPT will become the de facto way engineers produce high-quality code.

Ultimately, we see these two modes of interaction—real-time pairing and task delegation—converging. Developers will collaborate with AI agents across their IDEs and everyday tools to ask questions, get suggestions, and offload longer tasks, all in a unified workflow.

Looking ahead, we plan to introduce more interactive and flexible agent workflows. Developers will soon be able to provide guidance mid-task, collaborate on implementation strategies, and receive proactive progress updates. We also envision deeper integrations across the tools you already use: today Codex connects with GitHub, and soon you’ll be able to assign tasks from Codex CLI, ChatGPT Desktop, or even tools such as your issue tracker or CI system.

Software engineering is one of the first industries to experience significant AI-driven productivity gains, opening new possibilities for individuals and small teams. While we’re optimistic about these gains, we’re also collaborating with partners to better understand the implications of widespread agent adoption on developer workflows, skill development across people, skill levels, and geographies.

This is just the beginning—and we’re excited to see what you build with Codex.

Livestream replay

Appendix

System message

We are sharing the codex-1 system message to help developers understand the model’s default behavior and tailor Codex to work effectively in custom workflows. For example, the codex-1 system message encourages Codex to run all tests mentioned in the AGENTS.md file, but if you’re short on time, you can ask Codex to skip these tests.