跳至主要內容
OpenAI

2025年5月16日

發布產品

隆重介紹 Codex

一款以 codex-1 為核心的雲端軟體工程代理程式,具備多工處理能力。 目前已開放 ChatGPT Pro、Team 和 Enterprise 使用者使用,並將於近期提供給 Plus 使用者。

在柔和色調的程式碼主題背景上,儀表板顯示「我們接下來該寫什麼程式?」並搭配提示框、儲存庫 / 分支選擇器以及任務清單。
載入中…

2025 年 6 月 3 日更新;Codex 現已開放給 ChatGPT Plus 使用者使用。使用者在任務執行期間,也能夠讓 Codex 存取網際網路。請參閱更新記錄(在新視窗中開啟)文件(在新視窗中開啟)瞭解更多詳細資訊。


今天我們隆重推出 Codex 研究預覽版:一款以 codex-1 為核心的雲端軟體工程智慧體,具備多工處理能力。Codex 可為您執行各種任務,例如撰寫功能、回答程式碼庫相關問題、修正錯誤,並提出變更請求以供審查;每個任務都可以在獨立的雲端沙盒環境中執行,並預先載入您的儲存庫。

Codex 採用 codex-1 技術,該技術是針對軟體工程最佳化的 OpenAI o3 模型版本。Codex 透過強化學習,以多種環境的實際程式設計任務進行訓練,能產生貼近人類風格和變更請求偏好的程式碼,精準遵循指示,還能反覆執行測試直到通過為止。我們自今日起向 ChatGPT Pro、Enterprise 及 Team 使用者推出 Codex,並將於近期向 Plus 與 Edu 使用者開放。

Codex 運作方式

現在開始您可透過 ChatGPT 側邊欄使用 Codex,只需輸入提示然後點選「Code」,即可指派新的程式設計任務。如果您想向 Codex 詢問程式碼庫的相關問題,請點選「Ask」。每項任務都會在獨立的隔離環境中執行,且環境中已預先載入您的程式碼庫。Codex 不僅可以讀取和編輯檔案,還能執行測試工具、程式碼格式檢查器以及類型檢查器等指令。視任務的複雜程度,完成通常需要 1 到 30 分鐘,而且您可以即時監控 Codex 的執行進度。

Codex 完成任務後,便會在其環境中提交所做的變更。Codex 會透過引用終端機日誌與測試輸出,提供可驗證的操作證據,讓您能夠完整追蹤任務執行的每一步。接著您可以檢閱結果、要求進一步修改、建立 GitHub 變更請求,或直接將變更整合到本機環境中。您可以在 Codex 中進行環境設定,讓它盡可能符合您的實際開發環境。

Codex 可以透過放置在您程式庫中的 AGENTS.md 檔案加以引導。這是與 README.md 類似的文字檔案,用來告訴 Codex 如何瀏覽您的程式碼庫、執行哪些測試指令,以及如何最有效地遵循您專案的標準作業流程。就像人類開發人員一樣,當 Codex 代理程式具備完善的開發環境、穩定的測試架構與清楚的文件說明時,其表現也能達到最佳狀態。 

在程式碼評估與內部基準測試中,即使缺乏 AGENTS.md 檔案或自訂開發框架,Codex-1 仍展現出強勁的效能。

有 23 個 SWE-Bench 已驗證的樣本因無法在我們內部基礎架構上執行而被排除。codex-1 以最高 192k 個權杖的情境長度和中等「推理強度」進行測試,這也是目前產品中已提供的設定。請參閱此處內容,瞭解 o3 評估相關詳情。

我們內部的 SWE 任務基準測試是一組的來自 OpenAI 實際情境的精選軟體工程任務。

打造安全可信賴的代理程式

我們依循漸進式部署策略,以研究預覽版的形式釋出 Codex。我們在設計 Codex 時將資安與透明度列為優先考量,讓使用者能夠驗證其輸出結果。隨著 AI 模型獨立處理複雜程式任務的情況日益普遍,且安全需求持續演變,這項防護機制的重要性也隨之提升。使用者可以透過引用、終端機日誌與測試結果來檢視 Codex 的成果。遇到不確定情況或測試失敗時,Codex 代理程式會明確傳達這些問題,讓使用者能夠據以進行後續決策。在整合與執行前,使用者仍必須手動審查與驗證代理程式產生的所有程式碼,這一點仍至關重要。

藍色背景中顯示程式碼審查的螢幕截圖,畫面上疊有測試檔案的驗證畫面,顯示檔名引用是否正確,並附有摘要與通過測試的結果。
粉藍色背景中顯示程式碼審查的螢幕擷圖,畫面上疊有黑色終端機畫面,顯示檔名引用是否通過測試;同時可見「修正含特殊字元的 /diff 錯誤」的變更摘要與差異比對結果。

貼近人類偏好

codex-1 的主要訓練目標之一,是讓其輸出結果能夠高度貼近人類在程式設計上的偏好與標準。與 OpenAI o3 相比,Codex-1 更能穩定產生乾淨資料片段,便於即時人工審查並整合進標準工作流程中。

Please fix the following issue in the astropy/astropy repository. Please resolve the issue in the problem below by editing and testing code files in your current code execution session. The repository is cloned in the /testbed folder. You must fully solve the problem for your answer to be considered correct. Problem statement:Modeling's `separability_matrix` does not compute separability correctly for nested CompoundModels Consider the following model: ```python from astropy.modeling import models as m from astropy.modeling.separable import separability_matrix cm = m.Linear1D(10) & m.Linear1D(5) ``` It's separability matrix as you might expect is a diagonal: ```python >>> separability_matrix(cm) array([[ True, False], [False, True]]) ``` If I make the model more complex: ```python >>> separability_matrix(m.Pix2Sky_TAN() & m.Linear1D(10) & m.Linear1D(5)) array([[ True, True, False, False], [ True, True, False, False], [False, False, True, False], [False, False, False, True]]) ``` The output matrix is again, as expected, the outputs and inputs to the linear models are separable and independent of each other. If however, I nest these compound models: ```python >>> separability_matrix(m.Pix2Sky_TAN() & cm) array([[ True, True, False, False], [ True, True, False, False], [False, False, True, True], [False, False, True, True]]) ``` Suddenly the inputs and outputs are no longer separable? This feels like a bug to me, but I might be missing something?
Codex
OpenAI o3

防止濫用

如何防範 AI 驅動的軟體工程被惡意利用 (例如用於開發惡意軟體),已成為當前日益重要的議題。同時,保護措施也必須避免過度阻礙合法且有益的應用,因為這些應用有時會使用與惡意軟體開發類似的技術,例如低階核心工程。

為了在安全性與實用性之間取得平衡,我們將 Codex 訓練為能夠識別並明確拒絕針對惡意軟體開發的請求,同時清楚區分任務是否合法,並對合法任務提供支援。我們也強化了政策架構,納入嚴格的安全評估,以有效鞏固這些界限。我們已發佈 o3 系統說明卡的補充附錄,詳列這些評估結果。

安全執行

Codex 代理程式完全在雲端的安全隔離容器中執行。在執行任務期間,網路存取會被停用,代理程式所互動的程式碼,僅能來自使用者透過設定指令碼指定的 GitHub 程式庫,以及預先安裝的依賴套件。代理程式無法存取外部網站、API 或其他服務。

早期使用案例

OpenAI 的技術團隊已開始在日常的工具套件中納入 Codex 使用。OpenAI 工程師最常用它來減輕重複且範圍明確的任務,例如重構、重新命名和撰寫測試等,避免因此分散注意力。它同樣適用於搭建新功能框架、串接元件、修正錯誤,以及撰寫文件草稿。團隊正逐步養成使用 Codex 的習慣,包括排定值班問題優先順序、在工作日開始時規劃任務,以及將背景工作交由 Codex 處理,以便持續推進工作。Codex 可以減少切換工作內容的需要並提醒遺忘的待辦事項, 從而幫助工程師更快交付成果,並專注於最重要的工作。

在正式釋出前,我們也與一小群外部測試人員合作,深入了解 Codex 在不同程式碼庫、開發流程及團隊中的表現。

  • Cisco(在新視窗中開啟) 正在探索 Codex 如何能協助他們的工程團隊更快實現宏大的構想。身為早期設計夥伴,Cisco 正在其產品組合中的實際應用案例中評估 Codex,並向 OpenAI 團隊提供回饋,以協助塑造 Codex 的未來發展。
  • Temporal(在新視窗中開啟) 利用 Codex 加快功能開發、偵錯問題、撰寫與執行測試,以及重構大型程式碼庫。Codex 也能在背景中執行複雜任務,協助團隊保持專注,使工程師無須中斷工作流程,同時加快疊代速度。
  • Superhuman(在新視窗中開啟) 利用 Codex 加快處理小型而重複的任務,例如提高測試覆蓋率和修正整合失敗問題。除了最後的程式碼審查之外,Codex 還能幫助他們更快交付產品,讓產品經理能夠自行進行輕量的程式碼修改,而不必請工程師介入。
  • Kodiak(在新視窗中開啟) 正利用 Codex 協助撰寫偵錯工具、提升測試覆蓋率及重構程式碼,加速其自動駕駛技術「Kodiak Driver」的開發。Codex 也成為了寶貴的參考工具,提供相關背景資訊和過去的變更記錄,幫助工程師理解不熟悉的技術堆疊部分。

根據早期測試人員的經驗,我們建議同時指派多個代理程式處理範圍明確的任務,並嘗試不同類型的任務和提示,以便有效發掘模型的能力。

Codex CLI 更新內容

上個月,我們推出了 Codex CLI,一款可在終端機中執行的輕量級開源程式設計代理程式。它將 o3 和 o4-mini 等模型的強大能力導入您的本機工作流程,讓您能輕鬆搭配使用,加速任務完成。 

我們今天也同步推出 codex-1 的精簡版本,這是專為 Codex CLI 設計的 o4-mini 變體。這個新模型針對 CLI 環境中的低延遲程式設計問答與編輯任務進行了最佳化,兼具高效執行力與風格一致性,助您更快速完成工作。目前它已成為 Codex CLI 的預設模型,並可透過 codex-mini-latest 在 API 中取得。隨著我們持續改進 Codex-mini 模型,基礎版本將會定期更新。

我們也大幅簡化了將開發人員帳號連接到 Codex CLI 的流程。現在您可以直接使用 ChatGPT 帳號登入,並選擇要使用的 API 組織,無需手動產生和設定 API 權杖。我們會為您自動產生並設定 API 金鑰。而從今天稍後開始,Plus 與 Pro 用戶即可使用 ChatGPT 帳號登入 Codex CLI,並兌換價值 5 美元與 50 美元的免費 API 點數,有效期限為 30 天。

Codex 的提供方式、定價與使用限制

我們自今日起向全球 ChatGPT Pro、Enterprise 及 Team 用戶推出 Codex,並將於近期向 Plus 與 Edu 用戶開放。未來數週內,使用者可以免費且不限量使用 Codex,充分體驗其功能;之後,我們將推出限制流量的使用方式和彈性定價方案,讓您可以按需購買額外使用量。我們計劃將於近期開放 Plus 及 Edu 用戶使用。

對於使用 codex-mini-latest 進行開發的開發人員,可透過 Responses API 存取該模型,定價為每百萬輸入 token 1.50 美元和每百萬輸出 token 6 美元,並享有 75% 的提示快取折扣。

Codex 仍處於初期開發階段。做為研究預覽版本,目前尚無法支援前端作業的影像輸入等功能,也無法在代理程式運作中即時調整方向。此外,委派作業給遠端代理程式通常比進行互動式編輯花費更多時間,使用上可能需要一段適應期。假以時日,與 Codex 代理程式的互動將愈發像與同事進行非同步協作。隨著模型能力提升,我們預期代理程式未來將能在更長的時間範圍內處理更複雜的任務。

後續更新

我們所期望的未來,是開發人員能自主掌控自己負責的工作,並將其他部分交由代理程式處理,藉由 AI 輔助,加速工作流程並提升生產效率。為了達成這一目標,我們正在開發一系列 Codex 工具,既能支援即時協作,也能因應非同步委派的需求。 

在工作中搭配 Codex CLI 等 AI 工具,已快速成為業界常態,有助開發人員提升程式編寫效率,加快開發進度。但我們相信,Codex 在 ChatGPT 中導入的非同步多代理工作流程,將成為工程師產出高品質程式碼的標準工作模式。

我們認為,即時配對與任務委派這兩種互動模式,最終將合而為一。未來,開發人員將可在一個整合的工作流程中,透過 IDE 與日常工具與 AI 代理程式協作,提出疑問、獲得建議,並將冗長的任務交由其處理。

展望未來,我們計劃推出更具互動性與彈性的代理程式工作流程。開發人員很快就可以在任務進行過程中提供指引、共同擬定實作策略,並主動接收進度更新。我們也期待能和您目前使用的工具套件做更深入的整合:目前 Codex 已能連接 GitHub,不久後您就能從 Codex CLI、ChatGPT 桌面版,甚至是問題追蹤器或 CI 系統等工具中直接指派任務。

軟體工程是最早因 AI 驅動技術而大幅提升生產力的產業之一,為個人和小型團隊開創了全新可能。儘管我們對這些成效持樂觀態度,但也與合作夥伴攜手,深入探討代理程式廣泛應用對開發人員工作流程、跨團隊技能發展、技能水準及地域分布的影響。 

一切才剛開始,我們非常期待看到您利用 Codex 創造出精彩成果。

直播重播

附錄

系統訊息

我們公開 codex-1 的系統訊息,協助開發人員了解模型的預設行為並對 Codex 進行調整,以在自訂工作流程中更有效地運作。例如,codex-1 的系統訊息會鼓勵 Codex 執行 AGENTS.md 檔案中提及的所有測試,但如果時間有限,您也可以要求 Codex 跳過這些測試。

1
# Instructions
2
- The user will provide a task.
3
- The task involves working with Git repositories in your current working directory.
4
- Wait for all terminal commands to be completed (or terminate them) before finishing.
5

6
# Git instructions
7
If completing the user's task requires writing or modifying files:
8
- Do not create new branches.
9
- Use git to commit your changes.
10
- If pre-commit fails, fix issues and retry.
11
- Check git status to confirm your commit. You must leave your worktree in a clean state.
12
- Only committed code will be evaluated.
13
- Do not modify or amend existing commits.
14

15
# AGENTS.md spec
16
- 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.
17
- These files are a way for humans to give you (the agent) instructions or tips for working within the container.
18
- Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.
19
- 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.
20
- Instructions in AGENTS.md files:
21
- The scope of an AGENTS.md file is the entire directory tree rooted at the folder that contains it.
22
- For every file you touch in the final patch, you must obey instructions in any AGENTS.md file whose scope includes that file.
23
- Instructions about code style, structure, naming, etc. apply only to code within the AGENTS.md file's scope, unless the file states otherwise.
24
- More-deeply-nested AGENTS.md files take precedence in the case of conflicting instructions.
25
- Direct system/developer/user instructions (as part of a prompt) take precedence over AGENTS.md instructions.
26
- AGENTS.md files need not live only in Git repos. For example, you may find one in your home directory.
27
- 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.
28
- This applies even for changes that appear simple, i.e. documentation. You still must run all of the programmatic checks.
29

30
# Citations instructions
31
- 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:
32
1) `【F:<file_path>†L<line_start>(-L<line_end>)?】`
33
- 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.
34
- `line_start` is the 1-indexed start line number of the relevant output within that file.
35
2) `【<chunk_id>†L<line_start>(-L<line_end>)?】`
36
- 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.
37
- Line ends are optional, and if not provided, line end is the same as line start, so only 1 line is cited.
38
- 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.
39
- Do not cite completely empty lines inside the chunk, only cite lines that have content.
40
- Only cite from file paths and terminal outputs, DO NOT cite from previous pr diffs and comments, nor cite git hashes as chunk ids.
41
- Use file path citations that reference any code changes, documentation or files, and use terminal citations only for relevant terminal output.
42
- 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.
43
- 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.
44
- 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.

作者

OpenAI