新智元报道
编辑:编辑部 YXH
OpenAI 最强 AI 编程智能体真的来了!Codex 震撼上线,由 o3 优化版 codex-1 加持,多任务并行,半小时干完数天软件工程任务。
从今天起,AI 编程正式开启新时代!
刚刚,Greg Brockman 带队与 OpenAI 六人团队开启线上直播,震撼发布了一款云端 AI 编程智能体——Codex。
用奥特曼的话来说就是,一个人就能打造无数爆款应用的时代来了!
Codex 由新模型 codex-1 加持,这是 o3 的一个特调版本,专为软件工程量身打造。
它不仅能在云端沙盒环境中安全地并行处理多项任务,而且通过与 GitHub 无缝集成,还可以直接调用你的代码库。
它不仅仅是一款工具,更是一位「10x 工程师」,能够同时做到:
-
快速构建功能模块
-
深入解答代码库问题
-
精准修复代码漏洞
-
提交 PR
-
自动执行测试验证
过去,这些任务或许耗费开发者数小时乃至数日,如今 Codex 最多在 30 分钟内高效完成。
点击 ChatGPT 侧边栏,输入提示后,直接点击「代码」分配任务,或「提问」咨询代码库相关问题
通过强化学习,Codex 基于真实世界的编码任务和多样化环境训练,生成的代码不仅符合人类偏好,还能无缝融入标准工作流。
基准测试显示,codex-1 在 SWE-bench 上拿下 72.1% 的高分,一举击败了 Claude 3.7 以及 o3-high。
从今天起,Codex 将向全球 ChatGPT Pro、Enterprise 和 Team 用户正式开放,Plus 和 Edu 用户很快就能上手了。
可以说,AI 编程智能体 Codex 的横空出世,或将重塑软件开发的底层逻辑,彻底点燃了编程革命的火种。
Codex 多任务并行,AI 编程超级加速器
早在 2021 年,OpenAI 首次发布了 CodeX 模型,开启了「氛围编程」(vibe coding)的时代。
这种编程方式让开发者与 AI 协同工作,代码生产变得更加直观、高效。
几周前,OpenAI 又推出了 CodeX CLI,一款可在本地终端运行的智能体。
但这只是开始!
OpenAI 今天推出全新的 Codex 智能体,再次将软件工程推向一个全新的高度。
接下来,一睹 Codex 编码的惊艳表现吧。
连接 GitHub 账户后,OpenAI 研究员 Thibault Sottiaux 选择了一个开源仓库 preparedness repo。
然后,他收到了三个任务:
-
第一个是提问:让代码智能体 Codex 解释代码库,说明整体结构
-
第二个是代码任务:要求在代码库中查找并修复某个地方 bug
-
第三个任务是提问:遍历代码库,主动提出自己可以执行的任务建议
接下来演示中,Thibault 向 Codex 下达多个任务,比如拼写和语法纠错、智能任务委派、多仓库适配。
在纠错方面,他故意在指令中加入拼写错误,Codex 不仅理解了意图,还主动找出了代码库中的拼写和语法问题并修复,细致到令人惊叹。
当 Thibault 提出希望代码库「易维护、无 bug」的目标时,Codex 遍历代码库后,主动发现了可变默认值、不一致的超时设置等问题,并自行生成了修复任务。
这种「自我委派」能力,堪称智能体的巅峰表现。
值得注意的是,Codex 智能体运行在 OpenAI 计算基础设施上,与强化学习共享同一套久经考验的系统。
每个任务都在独立的虚拟沙盒中运行,配备专属的文件系统、CPU、内存、和网络策略,确保了高效安全。
除了 preparedness 仓库,Codex 还无缝处理了 CodeX CLI 库,展现其在不同项目中的泛化能力。
不论是开源项目,还是内部代码库,Codex 都游刃有余。
Codex 接收到了用户反馈的 bug,因为特殊字符文件名导致了 diff 命令报错。
在解决过程中,它不仅能复现问题,还可以编写测试脚本、运行 linter 检查,并生成 PR,整个过程仅需几分钟。
Thibault 直言,「这原本可能花费我 30 分钟,甚至几个小时完成」。
此外,OpenAI 研究员 Katy Shi 演示中强调,Codex 的 PR 包含了详细的摘要,清晰说明了修改内容和引用的代码,测试结果一目了然。
一番演示下来,Greg 表示,Codex 让自己深刻感受到了 AGI!
对齐人类偏好
实战 4 个开源库
OpenAI 训练 codex-1 的一个主要目标,是确保其输出能高度符合人类的编码偏好与标准。
与 OpenAI o3 相比,codex-1 能稳定生成更为简洁的代码修改补丁,可以直接供人工审查并集成到标准工作流程中。
为了体现 Codex 生成代码的简洁和高效,OpenAI 提供了 Codex 和 o3 对比的 4 个开源库实战实例:
astropy
astropy 是一个用于天文学的 Python 开源库。
第一个问题是 astropy/astropy 的仓库中,Modeling 模块中的 separability_matrix 无法正确计算嵌套 CompoundModels 的可分离性。
可以看到,在修改前后的代码版本对比中,使用 Codex 修改生成了十分简洁的代码。
相比之下,o3 修改的代码就显得有些冗长了,甚至还将一些「不必要」的注释加入了源代码中。
matplotlib
Matplotlib 是一个用于创建静态、动画和交互式可视化的 Python 综合性库。
这次问题是修复 Bug:在 mlab._spectral_helper 中的窗口校正(windows correction)不正确。
同样可以看到,Codex 修改代码的过程更为简洁。
django
Django 是基于 Python 的 Web 框架,这个问题是修复仅包含 duration(时长)的表达式在 SQLite 和 MySQL 上无法正常工作。
Codex 的修复过程依然优雅,并且相比 o3,还首先补上了缺少的依赖调用。
expensify
expensify 是一个围绕聊天的财务协作的开源软件。
OpenAI 给出的问题是「dd [HOLD for payment 2024-10-14] [$250] LHN - 删除缓存后,成员聊天室名称在 LHN 中未更新」。
同样可以看到 Codex 的问题定位和修改更为精准和有效,o3 甚至进行了一次无效的代码的修改。
OpenAI 团队已经用上了
OpenAI 的技术团队已经开始将 Codex 作为他们日常工具包的一部分。
OpenAI 的工程师最常使用 Codex 来执行重复且范围明确的任务,如重构、重命名和编写测试,这些任务会打断他们的专注。
它同样适用于搭建新功能、连接组件、修复错误和起草文档。
团队正在围绕 Codex 建立新的习惯:处理值班问题、在一天开始时规划任务,以及执行后台工作以保持进度。
通过减少上下文切换和提醒被遗忘的待办事项,Codex 帮助工程师更快地交付并专注于最重要的事情。
在正式发布前,OpenAI 与少数外部测试者合作,评估 Codex 在不同代码库、开发流程与团队环境中的实际表现:
-
Cisco作为早期设计合作伙伴,探索 Codex 在加速工程团队构思落地方面的潜力,并通过评估真实用例向 OpenAI 提供反馈,助力模型优化。
-
Temporal借助 Codex 实现功能开发、问题调试、测试编写与执行的加速,并用于重构大型代码库。Codex 还能在后台处理复杂任务,帮助工程师保持专注与高效迭代。
-
Superhuman利用 Codex 自动处理小型重复任务,如提高测试覆盖率和修复集成故障;还使产品经理能够无需工程介入(除代码审查外)完成轻量级代码更改,提升配对效率。
-
Kodiak在 Codex 支持下加速调试工具开发、测试覆盖和代码重构,推进其自动驾驶系统 Kodiak Driver 的研发。Codex 也作为参考工具,帮助工程师理解陌生代码栈,提供相关上下文与历史更改。
根据目前的使用经验来看,OpenAI 建议:可同时向多个代理分配边界清晰的任务,并尝试多种任务类型与提示方式,以更全面地发掘模型能力。
模型系统消息
通过以下系统消息,开发者可以了解 codex-1 的默认行为,并针对自己的工作流进行调整。
例如,系统消息会引导 Codex 运行 AGENTS.md 文件中提到的所有测试,但如果时间紧张,就可以要求 Codex 跳过这些测试。
# Instructions- The user will provide a task.- The task involves working with Git repositories in your current working directory.- Wait for all terminal commands to be completed (or terminate them) before finishing.# Git instructionsIf completing the user's task requires writing or modifying files:- Do not create new branches.- Use git to commit your changes.- If pre-commit fails, fix issues and retry.- Check git status to confirm your commit. You must leave your worktree in a clean state.- Only committed code will be evaluated.- Do not modify or amend existing commits.# AGENTS.md spec- Containers often contain AGENTS.md files. These files can appear anywhere in the container's filesystem. Typical locations include `/`, `~`, and in various places inside of Git repos.- These files are a way for humans to give you (the agent) instructions or tips for working within the container.- Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.- AGENTS.md files may provide instructions about PR messages (messages attached to a GitHub Pull Request produced by the agent, describing the PR). These instructions should be respected.- Instructions in AGENTS.md files: - The scope of an AGENTS.md file is the entire directory tree rooted at the folder that contains it. - For every file you touch in the final patch, you must obey instructions in any AGENTS.md file whose scope includes that file. - Instructions about code style, structure, naming, etc. apply only to code within the AGENTS.md file's scope, unless the file states otherwise. - More-deeply-nested AGENTS.md files take precedence in the case of conflicting instructions. - Direct system/developer/user instructions (as part of a prompt) take precedence over AGENTS.md instructions.- AGENTS.md files need not live only in Git repos. For example, you may find one in your home directory.- If the AGENTS.md includes programmatic checks to verify your work, you MUST run all of them and make a best effort to validate that the checks pass AFTER all code changes have been made. - This applies even for changes that appear simple, i.e. documentation. You still must run all of the programmatic checks.# Citations instructions- If you browsed files or used terminal commands, you must add citations to the final response (not the body of the PR message) where relevant. Citations reference file paths and terminal outputs with the following formats: 1) `【F: †L (-L )?】` - File path citations must start with `F:`. `file_path` is the exact file path of the file relative to the root of the repository that contains the relevant text. -`line_start` is the 1-indexed start line number of the relevant output within that file. 2) `【 †L (-L )?】` - Where `chunk_id` is the chunk_id of the terminal output, `line_start` and `line_end` are the 1-indexed start and end line numbers of the relevant output within that chunk.- Line ends are optional, and if not provided, line end is the same as line start, so only 1 line is cited.- Ensure that the line numbers are correct, and that the cited file paths or terminal outputs are directly relevant to the word or clause before the citation.- Do not cite completely empty lines inside the chunk, only cite lines that have content.- Only cite from file paths and terminal outputs, DO NOT cite from previous pr diffs and comments, nor cite git hashes as chunk ids.- Use file path citations that reference any code changes, documentation or files, and use terminal citations only for relevant terminal output.- Prefer file citations over terminal citations unless the terminal output is directly relevant to the clauses before the citation, i.e. clauses on test results. - For PR creation tasks, use file citations when referring to code changes in the summary section of your final response, and terminal citations in the testing section. - For question-answering tasks, you should only use terminal citations if you need to programmatically verify an answer (i.e. counting lines of code). Otherwise, use file citations.
Codex CLI 更新
上个月,OpenAI 推出了一款轻量级开源工具——CodexCLI,可以让 o3 和 o4-mini 等强大模型直接运行在本地终端中,帮助开发者更快完成任务。
这一次,OpenAI 同时发布了专为 Codex CLI 优化的小模型版本——codex-1 的 o4-mini 版本。
它具备低延迟、强指令理解力和代码编辑能力,现已成为 Codex CLI 的默认模型,同时也可通过 API 使用(名称为 codex-mini-latest),并将持续迭代更新。
此外,Codex CLI 的登录方式也简化了,开发者现在可以直接用 ChatGPT 账户登录,选择 API 组织,系统将自动生成并配置 API 密钥。
为了鼓励使用,从今天起 30 天内,使用 ChatGPT 账户登录 Codex CLI 的用户将获得免费额度:Plus 用户获得 5 美元 API 使用额度;Pro 用户获得 50 美元。
Codex 贵不贵
在接下来的几周内,所有用户可以「量大管饱」的试用 Codex 功能。
随后,OpenAI 将引入限流机制和灵活定价,支持按需购买额外使用量。
对于开发者,codex-mini-latest模型已在 Responses API 上提供,价格为:
-
每百万输入 Token:$1.50
-
每百万输出 Token:$6.00
-
并享有 75% 的提示缓存折扣
Codex 当前仍处于研究预览阶段,尚不支持图像输入等前端能力,也暂不具备在任务执行中进行实时纠正的能力。
此外,委派任务给 Codex 智能体的响应时间较长,用户可能需要适应这类异步协作的工作方式。
随着模型能力不断提升,Codex 将能处理更复杂、更持久的开发任务,逐步成为更像「远程开发伙伴」的存在。
下一步是什么
OpenAI 的目标是开发者专注自己擅长的工作,其余任务交由 AI 代理处理,从而提升效率与生产力。
Codex 将支持实时协作与异步任务委托,两种工作模式将逐步融合。
Codex CLI 等工具已经成为开发者加速编码的标配,而由 ChatGPT 中的 Codex 引领的异步、多智能体协作流程,有望成为工程师高效产出高质量代码的新范式。
未来,开发者将能在 IDE 和日常工具中与 AI 协同工作——提问、获取建议、委派复杂任务,所有操作整合在一个统一的工作流程中。
OpenAI 计划进一步提升交互性和灵活性:
-
支持任务中途提供指导
-
与 AI 协作实施策略
-
接收主动进度更新
-
与常用工具(如 GitHub、CLI、问题跟踪器、CI 系统)深度集成,便捷分配任务
软件工程正成为首批因 AI 而大幅提效的行业之一,将全面释放个人与小团队的巨大潜力。
与此同时,OpenAI 也正与合作伙伴共同研究智能体的广泛应用将如何影响开发流程、技能发展和全球人才分布。
参考资料: