Codex CLI:權威技術參考
# Codex CLI v0.142.0(穩定版,6月22日)在v0.140.0的/usage與/import工具以及GPT-5.5預設值基礎上,新增/usage點數兌換、/plugins精選/工作區/共享分類、可設定的推出權杖預算、多代理委派模式,以及索引式網頁搜尋模式。涵蓋架構、沙盒/核准、AGENTS.md、MCP、技能。
Codex CLI v0.142.0(穩定版,6月22日)在v0.140.0的/usage與/import工具以及GPT-5.5預設值基礎上,新增/usage點數兌換、/plugins精選/工作區/共享分類、可設定的推出權杖預算、多代理委派模式,以及索引式網頁搜尋模式。涵蓋架構、沙盒/核准、AGENTS.md、MCP、技能。
TL;DR: Codex 是多介面 coding agent,會讀取您的程式碼庫、在 OS 層級 sandbox 中執行命令、修補檔案,並將任務委派到雲端。掌握 5 個核心系統(config.toml、sandbox/approval model、AGENTS.md、MCP 和 skills),Codex 就會成為倍增器。使用 profiles 進行情境切換、用
/compact管理 context budget、用/goal保存工作目標,並透過 AGENTS.md 撰寫可跨 Codex、Cursor、Amp 等工具運作的專案指令。GPT-5.5(2026年4月23日推出)是 Codex 中建議的預設模型:Codex 內提供 400K context window(API 中為 1M)、每 MTok $5/$30,Terminal-Bench 2.0 SOTA 達 82.7%。83 截至 CLI v0.140.0(stable,2026年6月15日),/usage會顯示每日、每週與累計的帳戶 token activity;sessions 可透過codex delete//delete永久刪除(含確認防護);/import可選擇性從 Claude Code 遷移設定、專案 config 和近期 chats;輸入@預設會開啟統一的 mentions menu,涵蓋檔案、plugins 和 skills;受管理的 Amazon Bedrock API-key authentication 也同步推出,並支援 CLI 與 MCP OAuth credentials 的加密本機儲存;實驗性的/realtime語音控制已從 TUI 移除。102 截至 CLI v0.139.0(stable,2026年6月9日),code mode 可直接呼叫獨立 web search(也包含巢狀 JavaScript tool calls),並接收純文字結果;tool/connector input schemas 現在會保留oneOf/allOf結構,以提升大型 schema 與 MCP 相容性;codex doctor新增 editor 和 pager 環境詳細資料(並在 JSON 中遮蔽敏感值);plugin marketplace 會在codex plugin marketplace list --json中公開 sources,且 cached-catalog listing 更快。105 v0.138.0(6月8日)新增/app,可在 macOS 和 Windows 將 CLI session 交接給 desktop app;向模型公開本機圖片路徑;讓 reasoning-effort 選擇更彈性;並提供 plugin automation 結構化 JSON output。106 v0.137.0(6月4日)推出 multi-agent v2(runtime 依 thread 保留、更乾淨的 follow-up 與 metadata 預設值、hide_spawn_agent_metadata預設為 true)、F13–F24 TUI keybindings,以及具備 per-turn catalog resolution 的 v1 skills extension。107 截至 CLI v0.135.0(2026年5月28日),codex doctor會回報更豐富的 environment、Git、terminal、app-server 與 thread inventory;當 TUI 透過 remote 連線時,/status會顯示 remote connection 詳細資料與 server version;vim mode 新增 text-object editing,改善 word/line-end 行為,並支援可設定的 interrupt-turn;/permissions現在理解具名 permission profiles並顯示自訂項目;封裝版 Codex builds 會在支援的 macOS 上探索並使用內建 patched zsh helper;Python SDK 則公開易懂的Sandboxpresets,可用於 thread 和 turn APIs。109 v0.134.0(2026年5月26日)導入本機 conversation history 搜尋,支援不分大小寫的內容比對與結果預覽;讓--profile成為 CLI、TUI permissions 與 sandbox flows 的主要 profile selector(舊版 profile configs 會被拒絕,並附遷移指引);改善 MCP 設定,支援 per-server environment targeting 與 streamable HTTP servers 的 OAuth options;透過保留本機$ref/$defs並壓縮過大的 schemas,讓 connector tool schemas 更可靠;允許 read-only MCP tools 在宣告readOnlyHint時並行執行;並為 extension tools 加入更豐富的 extension 與 hook context,包括 conversation history。101 v0.133.0(2026年5月21日)預設啟用 goals,並提供專用儲存與進度追蹤;codex remote-control新增 foreground readiness/status 與 daemon-style start/stop;permission profiles 取得 list APIs、inheritance、受管理的requirements.toml、runtime refresh,以及更強的 Windows sandbox 整合;plugin discovery 會顯示已安裝版本、marketplace roots 與 remote collections;extensions 可觀察 subagent start/stop、tool execution、turn metadata,以及 async approval/turn processing。5月21日的 Codex app 更新加入 Appshots,可擷取最前方 Mac 視窗;Goal mode 在 app/IDE/CLI 全面可用;改善 in-app browser annotation;並為符合資格的 Mac 使用者提供可選用的 locked Computer Use。99100 v0.132.0(2026年5月20日)新增 Python SDK first-class auth、更簡單的 text-only turn APIs、更豐富的TurnResult、codex exec resume --output-schema、更快的 TUI startup、auth-backed remote executor registration,以及 app-server turns 中的 image-fidelity preservation。請繼續優先使用明確的 sandbox/approval flags 或 permission profiles,而不是舊版--full-auto;js_repl仍已移除。86878991969798
Codex 是以 multi-surface coding agent 的方式運作,不是只會撰寫程式碼的 chatbot。CLI 會讀取您的程式碼庫、在 sandbox 中執行命令、修補檔案、透過 MCP 連接外部服務,並將長時間執行的任務委派到雲端。它在本機執行,卻具備全域思考能力;同一套智慧會依您的工作方式驅動 5 種不同介面,包括新的 Chrome extension,讓 Codex 可在瀏覽器中運作,而不會接管瀏覽器。90
隨興使用與高效使用 Codex 的差異,取決於 5 個核心系統。掌握它們後,Codex 就會成為倍增器:
- Configuration system:透過
config.toml控制行為 - Sandbox & approval model:管控 Codex 可執行的動作
- AGENTS.md:定義專案層級的操作契約
- MCP protocol:將能力延伸到外部服務
- Skills system:封裝可重複使用的領域專業知識
我花了數個月,在 production codebases、CI/CD pipelines 和團隊工作流程中並行使用 Codex 與 Claude Code。本指南濃縮了這些經驗,整理成我剛開始時最希望擁有的完整參考。每項功能都包含實際語法、真實 config 範例,以及容易讓資深使用者踩坑的邊界情境。
穩定性註記:標示為
[EXPERIMENTAL]或under development的功能,可能會在不同版本間變更。截至 v0.133.0(2026年5月21日),goals 預設啟用,permission profiles 成為 first-class managed surface,plugin discovery 更容易檢視,remote-control 也更容易以 foreground 或 daemonized app-server command 執行。Codex Cloud 和 code mode 仍屬實驗性或開發中;而 core CLI、sandboxing、AGENTS.md、config.toml、Skills、hooks、multi-agent tools、plugins、Browser、Computer Use 和 Appshots,則依平台與方案不同,屬於穩定或有文件記載的使用者介面。v0.132.0 補齊 Python SDK auth 與 structured resume automation;v0.131.0 新增codex doctor、統一的@mention search、marketplace CLI commands、version-aware plugin sharing、由 daemon 管理且可於 runtime enable/disable 的 remote-control、registry-backed environments,以及額外的 Windows sandbox hardening。969798 舊版--full-auto仍已棄用,js_repl仍已移除。8687
重點摘要
- 5種介面,同一個大腦:CLI、桌面 App、IDE extension、cloud tasks,以及新的 Chrome extension,都共用同一套 GPT-5.x-Codex 智慧;請選擇最符合您工作流程的介面。90
- 作業系統層級沙箱:Codex 會在核心層級強制執行檔案系統與網路限制(macOS 使用 Seatbelt,Linux 使用 Landlock + seccomp),而不是在容器內執行。
- AGENTS.md 可跨工具使用:您的專案指令可在 Codex、Cursor、Copilot、Amp、Jules、Gemini CLI、Windsurf、Cline、Aider、Zed,以及 60,000 多個開放原始碼專案中運作。撰寫一次,到處使用。
- Profiles 可省下切換情境的成本:定義具名設定預設值(
fast、careful、auto),並使用--profile在它們之間切換。 - 情境管理很重要:GPT-5.5 在 Codex 中提供 400K 情境視窗,在 API 中提供 1M;GPT-5.4 mini 也提供 400K,適合較低延遲的 subagent 工作;GPT-5.3-Codex 提供 272K 輸入。請主動使用
/compact、聚焦的提示,以及@file參照來管理 token 預算。83
如何使用本指南
這是一份超過 2,500 行的參考文件,請從符合您經驗程度的位置開始:
| 經驗 | 從這裡開始 | 接著探索 |
|---|---|---|
| Codex 新手 | 安裝 → 快速開始 → 心智模型 | 設定、沙箱 |
| 日常使用者 | AGENTS.md、Skills、Plan Mode | MCP、Hooks |
| 團隊主管/企業 | 企業部署 → 最佳實務 | 決策框架、工作流程範例 |
| 從其他工具遷移 | 遷移指南 | 決策框架 |
最後的快速參考卡提供所有主要命令的易讀摘要。
Codex 如何運作:心智模型
深入功能之前,請先理解 Codex 的架構如何影響您使用它的一切方式。此系統橫跨 4 種介面運作,背後由共享的智慧層支援:
┌─────────────────────────────────────────────────────────┐
│ CODEX SURFACES │
├─────────────────────────────────────────────────────────┤
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌────────┐ │
│ │ CLI │ │ Desktop │ │ IDE │ │ Cloud │ │
│ │ Terminal │ │ App │ │Extension │ │ Tasks │ │
│ └──────────┘ └──────────┘ └──────────┘ └────────┘ │
│ Local exec Multi-task Editor-native Async │
│ + scripting + worktrees + inline edits detached │
├─────────────────────────────────────────────────────────┤
│ EXTENSION LAYER │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ MCP │ │ Skills │ │ Apps │ │ Search │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
│ External tools, reusable expertise, ChatGPT │
│ connectors, web search (cached + live) │
├─────────────────────────────────────────────────────────┤
│ SECURITY LAYER │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Sandbox (Seatbelt / Landlock / seccomp) │ │
│ │ + Approval Policy (untrusted → never) │ │
│ └─────────────────────────────────────────────────┘ │
│ OS-level filesystem + network restrictions │
├─────────────────────────────────────────────────────────┤
│ CORE LAYER │
│ ┌─────────────────────────────────────────────────┐ │
│ │ GPT-5.x-Codex Intelligence │ │
│ │ Tools: Shell, Patch, Read, Web Search │ │
│ │ (legacy artifact, read_file, grep_files │ │
│ │ removed in v0.117.0) │ │
│ └─────────────────────────────────────────────────┘ │
│ Shared model across all surfaces; costs tokens │
└─────────────────────────────────────────────────────────┘
核心層:GPT-5.x 模型系列驅動所有功能。截至 2026年4月23日,若可用,gpt-5.5 是建議模型,在 Codex 中提供 400K 情境(在 API 中為 1M),Terminal-Bench 2.0 SOTA 達 82.7%。gpt-5.4 在推出期間仍是備援預設值(1M 情境、原生 computer use)。8364它會讀取檔案、撰寫修補、執行 shell 命令,並推理您的程式碼庫。當情境填滿時,Codex 會壓縮對話以釋出空間。此層會消耗 token。
安全層:Codex 執行的每個命令都會通過作業系統層級沙箱。在 macOS 上,Apple 的 Seatbelt framework 會強制執行核心層級限制。在 Linux 上,Landlock + seccomp 會篩選檔案系統與 syscall 存取。沙箱在核心層級運作,而不是在容器內。接著 approval policy 會決定何時要求人工確認。
擴充層:MCP 連接外部服務(GitHub、Figma、Sentry)。Skills 封裝可重複使用的工作流程,Codex 會依需求載入。Apps 連接至 ChatGPT connectors。Web search 則從網際網路加入即時情境。
介面層:CLI 適合終端機進階使用者與自動化。桌面 App 適合多執行緒專案管理。IDE extension 適合編輯、編譯、測試循環。Cloud 適合可獨立執行的非同步任務。
關鍵洞見:多數使用者只會使用一種介面。進階使用者會使用全部 5 種:Cloud 用於長時間執行的任務,CLI 用於可預期的 repo 操作,IDE extension 用於緊密的程式撰寫循環,桌面 App 用於規劃與協作,Chrome 則用於已登入的瀏覽器工作流程。
目錄
- 如何安裝 Codex?
- 快速開始:您的第一次 session
- 核心互動介面
- 設定系統深入解析
- 我該選擇哪個模型?
- Codex 費用是多少?
- 決策框架
- Sandbox 與 Approval System 如何運作?
- AGENTS.md 如何運作?
- Hooks
- 什麼是 MCP(Model Context Protocol)?
- Code Mode
- JavaScript REPL Runtime
- 什麼是 Skills?
- Plugins
- Plan Mode 與協作
- Memory System
- Session Management
- Non-Interactive Mode (codex exec)
- Codex Cloud 與 Background Tasks
- Codex Desktop App
- GitHub Action 與 CI/CD
- Codex SDK
- 效能最佳化
- 如何偵錯問題?
- 企業部署
- 最佳實務與反模式
- 工作流程範例
- 遷移指南
- 快速參考卡
- Changelog
- References
如何安裝 Codex?
套件管理器
# npm (recommended)
npm install -g @openai/codex
# Homebrew (macOS)
brew install --cask codex
# winget (Windows)
winget install OpenAI.Codex
# Upgrade to latest
npm install -g @openai/codex@latest
直接安裝指令碼(v0.106.0+)
macOS 與 Linux 可使用單行安裝指令碼,該指令碼以 GitHub release asset 形式提供:60
curl -fsSL https://github.com/openai/codex/releases/latest/download/install.sh | sh
此指令碼會自動偵測您的平台與架構,下載正確的二進位檔,並將其放到您的 PATH 上。
二進位檔下載
若環境沒有 npm 或 Homebrew,請從 GitHub Releases下載平台專用二進位檔1:
| 平台 | 二進位檔 |
|---|---|
| macOS Apple Silicon | codex-aarch64-apple-darwin.tar.gz |
| macOS x86_64 | codex-x86_64-apple-darwin.tar.gz |
| Linux x86_64 | codex-x86_64-unknown-linux-musl.tar.gz |
| Linux arm64 | codex-aarch64-unknown-linux-musl.tar.gz |
系統需求
- macOS:Apple Silicon 或 Intel(透過 Seatbelt 提供完整 sandbox 支援)
- Linux:x86_64 或 arm64(透過 Landlock + seccomp 提供 sandbox)
- Windows:使用受限權杖的原生 sandbox(已於 v0.100.0 從實驗性功能升級)。也支援 WSL2
驗證
codex login # Interactive OAuth (recommended)
codex login --device-auth # OAuth device code flow (headless)
codex login --with-api-key # API key from stdin
codex login status # Check auth state (exit 0 = logged in)
codex logout # Clear stored credentials
兩種驗證路徑:
- ChatGPT 帳戶(建議):使用您現有的 Plus、Pro、Team、Business、Edu 或 Enterprise 訂閱登入。可完整存取功能,包括雲端任務。
- API 金鑰:透過
CODEX_API_KEY環境變數或codex login --with-api-key設定。部分功能(雲端 threads)可能無法使用。
專家提示:憑證儲存可透過
config.toml中的cli_auth_credentials_store設定。選項包括:file(預設)、keyring(OS 鑰匙圈)或auto(可用時使用 keyring,否則退回 file)。
Shell 自動補全
# Generate completions for your shell
codex completion bash > /etc/bash_completion.d/codex
codex completion zsh > ~/.zsh/completions/_codex
codex completion fish > ~/.config/fish/completions/codex.fish
驗證安裝
codex --version
# codex-cli 0.133.0
快速開始:您的第一次 Session
從零開始,5 分鐘內進入可生產狀態。
1. 安裝並驗證:
npm i -g @openai/codex # Install
codex login # Log in with your OpenAI account
2. 前往專案:
cd ~/my-project # Any git repo works
3. 啟動 Codex:
codex
您會看到互動式 TUI。Codex 會自動讀取您的專案結構。
4. 提出問題:
> What does this project do? Summarize the architecture.
Codex 會讀取關鍵檔案並說明程式碼庫。在預設的 suggest 模式下不會進行任何變更。
5. 進行變更:
> Add input validation to the login endpoint
Codex 會以 diff 形式提出編輯。請檢閱後以 y 核准,或以 n 拒絕。
6. 使用 slash command:
> /plan Refactor the database layer to use connection pooling
Codex 會建立計畫但不執行。檢閱計畫後,核准即可開始執行。
7. 檢查成果:
> /diff
查看 Codex 在目前 session 中所做的所有變更。
接下來:
- 設定包含專案指示的 AGENTS.md(請參閱 AGENTS.md 如何運作?)
- 為您的工作流程設定 profile(請參閱 Profiles)
- 嘗試使用 codex exec 進行非互動式自動化(請參閱 Non-Interactive Mode)
核心互動介面
Codex 提供 4 種由相同智慧支援的不同介面。每個介面都針對不同工作流程模式最佳化。
1. 互動式 CLI(Terminal UI)
codex # Launch TUI
codex "fix the failing tests" # Launch with initial prompt
codex -m gpt-5.5 # Specify model
codex --sandbox workspace-write --ask-for-approval on-request
Terminal UI 是全螢幕應用程式,包含:
- Composer:輸入提示、用
@附加檔案、用!前綴執行 shell commands - Output pane:串流模型回應、tool calls 與 command output
- Status bar:模型、token 使用量、git branch、sandbox mode
主要 TUI 快捷鍵:
| Shortcut | Action |
|---|---|
@ |
模糊檔案搜尋(附加至 context) |
!command |
直接執行 shell command |
Ctrl+G |
開啟外部編輯器($VISUAL / $EDITOR) |
Ctrl+R |
反向歷史搜尋(v0.121.0+) — 以 readline 風格搜尋先前提示,包含較早回合中發出的 slash commands82 |
Enter(執行中) |
在回合進行中插入新指令 |
Esc 兩次 |
編輯先前訊息 |
| 方向鍵 | 瀏覽草稿歷史 |
狀態列變更(v0.121.0):狀態列中舊的 context-window meter 已由context 百分比指示器取代,用來顯示您的 context window 已使用多少。如果您有 scripts 或 hooks 會解析狀態列,請檢查這項格式變更。82 有新版本可用時,Codex 也會顯示 CLI 更新公告。
TUI 中可用的 Slash commands:
| Command | Description |
|---|---|
/quit 或 /exit |
離開 CLI |
/new |
在同一 session 中開始新 conversation |
/resume |
恢復已儲存的 conversation |
/fork |
將目前 conversation fork 成新 thread |
/model |
切換模型與 reasoning effort |
/compact |
摘要 conversation 以釋放 tokens |
/diff |
顯示 git diff,包含未追蹤檔案 |
/review |
對 working tree 進行 code review |
/plan |
進入 plan mode |
/goal |
建立、暫停、恢復或清除持久化 work goals(v0.128.0+)。v0.133.0:goals 預設啟用,由專用儲存支援,並可跨 active turns 追蹤進度;OpenAI 現已將 Goal mode 記載為 Codex app、IDE extension 與 CLI 全面可用的功能。98100 |
/vim |
在 composer 中切換 modal Vim 編輯(v0.129.0+)。可透過 TUI keymap 設定,將 Vim 設為預設編輯模式。89 |
/hooks |
從 TUI 瀏覽並切換 lifecycle hooks(v0.129.0+)。探索可用 hooks、查看哪些已啟用,並在不離開 session 的情況下切換個別 hooks。89 |
/mention |
將檔案附加至 conversation |
/init |
產生 AGENTS.md scaffold |
/status |
Session config 與 token 使用量 |
/usage |
每日、每週與累計帳戶 token activity(v0.140.0+)。 v0.142.0:也會顯示並兌換已取得的 usage-limit reset credits,並提供確認、重試與重新整理後的可用狀態。102104 |
/import |
選擇性匯入 Claude Code 的設定、project configuration 與最近 chats(v0.140.0+)。102 |
/delete |
永久刪除目前 session(v0.140.0+) — 也包含 CLI 上的 codex delete 與 app-server 上的 thread/delete,且全都具備確認防護。102 |
/permissions |
設定 approval policy |
/personality |
溝通風格(friendly/pragmatic/none) |
/mcp |
列出已設定的 MCP tools |
/apps |
瀏覽 ChatGPT connectors |
/ps |
顯示背景 terminals |
/skills |
存取並呼叫 skills |
/plugins |
瀏覽並管理已安裝 plugins(v0.117.0+);v0.129.0 新增 workspace sharing 與 marketplace operations。89 |
/title |
設定 terminal window title(v0.117.0+) |
/config |
列印有效 config values 與 sources |
/statusline |
設定 TUI footer;v0.129.0 新增選用的 theme-aware status line,含 PR 與 branch-change 摘要。89 |
/feedback |
將 logs 傳送給 Codex maintainers |
/logout |
登出 |
Workflow picker 重新設計(v0.129.0):Resume 與 fork 現在可從重新設計的 picker 更輕鬆存取,新的 raw scrollback mode 則讓您在需要逐字複製 commands 或 model output 時,捲動查看未渲染的 transcript。對於分診冗長 debugging session,或將 output pipe 到其他 tool 時,尤其實用。89
統一的
@mentions menu(v0.140.0):現在在 composer 輸入@會預設開啟單一 mentions menu,涵蓋 files、plugins 與 skills,取代原本僅限檔案的附加流程;只需一次按鍵即可參照任何 project resource。102
2. Codex Desktop App(macOS + Windows)
codex app # Launch desktop app (auto-installs if missing)
Desktop app 新增了 CLI 沒有的能力:
- Multi-tasking:同時在不同 projects 中執行多個 parallel agents
- Git worktree isolation:每個 thread 都在 repo 的隔離副本上工作
- Inline diff review:不離開 app 即可 stage、revert 與 commit changes
- Integrated terminal:每個 thread 都有可執行 commands 的 terminal
- Conversation forking:分支 conversations 以探索替代方案
- Floating pop-out windows:將 conversations 分離成可攜式 windows
- Automations:排程 recurring tasks(issue triage、CI monitoring、alert response)
- Appshots:將最前方的 Mac app window 以 screenshot 加上可用文字附加到 thread
- In-app browser comments:預覽本機或公開 pages、留下 element/area comments,並讓 Codex 處理精準的視覺回饋
- Computer Use:讓 Codex 操作允許的 Mac apps,以進行有範圍的 GUI 工作;locked use 需針對合格的 remote Mac Computer Use turns 選擇啟用
何時使用 app,何時使用 CLI:當您要協調多個 workstreams,或需要視覺化 diff review 時,請使用 desktop app。若需要 terminal composability、scripting 或 CI/CD integration,則使用 CLI。
3. IDE Extension(VS Code、Cursor、Windsurf)
Codex IDE extension 會直接整合到您的 editor:
- Agent mode 預設啟用:讀取檔案、進行編輯、執行 commands
- Inline edits:在 active files 中提供具 context awareness 的建議
- Shared sessions:Sessions 會在 CLI 與 IDE extension 之間同步
- 相同 authentication:使用 ChatGPT account 或 API key 登入
請從 VS Code Marketplace 或 Cursor/Windsurf extension stores 安裝。3
4. Codex Cloud [EXPERIMENTAL]
Cloud tasks 會在 OpenAI 管理的 environments 中非同步執行:
- Fire and forget:將 tasks 排入佇列,使其獨立於您的本機電腦執行
- Parallel execution:同時執行多個 cloud tasks
- PR creation:Codex 會從完成的 work 建立 pull requests
- Local apply:使用
codex apply <TASK_ID>將 cloud results 拉回您的本機 repo
codex cloud list # List recent cloud tasks
codex apply <TASK_ID> # Apply diff from a specific cloud task
Cloud tasks 也可從 chatgpt.com/codex 存取。4
5. Codex for Chrome [NEW]
Codex 以 Chrome browser extension 形式推出,在 CLI、desktop app、IDE extension 與 cloud 之外新增第 5 種介面。此 extension 的設計是伴隨您的正常瀏覽流程,而不是接管瀏覽器:Codex 會在背景跨 tabs 平行運作,而您仍可掌控它能接觸哪些 sites。90
- Parallel tab execution:Codex 可同時跨多個 tabs 操作,而不會鎖定前景 tab。
- Per-site control:您可 allow-list Codex 能互動的 websites;預設沒有存取權。
- Browser as the workbench:此 extension 最適合頁面本身就是 source of truth 的 app-and-website 工作,例如 admin consoles、internal dashboards、content-management UIs、ticket systems;它並不是本機 repos 上 CLI 的替代品。
- Same brain:Codex for Chrome 執行與其他介面相同的 GPT-5.x-Codex intelligence,因此可在 CLI 中運作的 AGENTS.md 或 skills configuration,也會將相同慣例帶入 browser-driven work。
請從 Codex Chrome extension docs 安裝。90
Configuration System 深入剖析
Codex 使用 TOML 進行設定。了解優先順序層級至關重要,因為它會決定設定衝突時哪個值生效。
優先順序(由高到低)
- Session overrides(最高):CLI flags(
--model、--sandbox、--ask-for-approval、--search、--enable/--disable、--profile)以及-c key=valueoverrides - Project config(
.codex/config.toml,從 CWD 往上搜尋至專案根目錄;最接近的目錄優先) - User config(
$CODEX_HOME/config.toml,預設為~/.codex/config.toml) - System config(Unix 上的
/etc/codex/config.toml) - 內建預設值(最低)
requirements.toml作為政策約束層,會在一般設定合併後,限制使用者可選取的值。請參閱 Enterprise Deployment。
Config 檔案位置
| 範圍 | 路徑 | 用途 |
|---|---|---|
| User | ~/.codex/config.toml |
個人預設值 |
| Project | .codex/config.toml |
每個 repo 的 overrides |
| System | /etc/codex/config.toml |
整台機器通用的預設值 |
| Managed | /etc/codex/requirements.toml |
管理員強制執行的政策約束 |
專家提示:
CODEX_HOME環境變數會覆寫預設的~/.codex目錄。適用於 CI/CD 或多帳號設定。
完整 Configuration 參考
# ~/.codex/config.toml — annotated reference
# ─── Model Selection ───────────────────────────────────
model = "gpt-5.5" # Recommended model when available
model_provider = "openai" # Provider (openai, oss, or custom provider id)
model_context_window = 400000 # Token count available to active model (override)
model_auto_compact_token_limit = 200000 # Threshold triggering automatic history compaction
model_reasoning_effort = "medium" # minimal|low|medium|high|xhigh (model-dependent)
model_reasoning_summary = "auto" # auto|concise|detailed|none
model_verbosity = "medium" # low|medium|high
personality = "pragmatic" # none|friendly|pragmatic
review_model = "gpt-5.5" # Optional model for /review command
service_tier = "fast" # Preferred service tier for new turns
oss_provider = "lmstudio" # lmstudio|ollama (used with --oss)
# ─── Sandbox & Approval ───────────────────────────────
sandbox_mode = "workspace-write" # read-only|workspace-write|danger-full-access
approval_policy = "on-request" # untrusted|on-request|never
[sandbox_workspace_write]
writable_roots = [] # Additional writable paths
network_access = false # Allow outbound network
exclude_tmpdir_env_var = false # Exclude $TMPDIR from sandbox
exclude_slash_tmp = false # Exclude /tmp from sandbox
# ─── Web Search ────────────────────────────────────────
web_search = "live" # Web search mode (constrained by allowed modes)
# ─── Instructions ──────────────────────────────────────
developer_instructions = "" # Additional injected instructions
model_instructions_file = "" # Custom instructions file path
compact_prompt = "" # Custom history compaction prompt
# ─── Shell Environment ─────────────────────────────────
allow_login_shell = false # Allow login shell semantics (loads .profile/.zprofile)
[shell_environment_policy]
inherit = "all" # all|core|none
ignore_default_excludes = false # Set true to keep KEY/SECRET/TOKEN vars
exclude = [] # Glob patterns to exclude
set = {} # Explicit overrides
include_only = [] # Whitelist patterns
# ─── Authentication ────────────────────────────────────
cli_auth_credentials_store = "file" # file|keyring|auto
forced_login_method = "chatgpt" # chatgpt|api
mcp_oauth_callback_port = 0 # Fixed port for MCP OAuth callback (0 = random)
mcp_oauth_credentials_store = "auto" # auto|file|keyring
# ─── History & Storage ─────────────────────────────────
[history]
persistence = "save-all" # save-all|none
max_bytes = 0 # Cap size (0 = unlimited)
tool_output_token_limit = 10000 # Max tokens per tool output
log_dir = "" # Custom log directory
sqlite_home = "" # Override SQLite-backed resumable state location
# ─── UI & Display ──────────────────────────────────────
file_opener = "vscode" # vscode|vscode-insiders|windsurf|cursor|none
hide_agent_reasoning = false
show_raw_agent_reasoning = false
check_for_update_on_startup = true
[tui]
notifications = false # Enable notifications
notification_method = "auto" # auto|osc9|bel
animations = true
show_tooltips = true
alternate_screen = "auto" # auto|always|never
status_line = ["model", "context-remaining", "git-branch"]
# ─── Project Trust ─────────────────────────────────────
project_doc_max_bytes = 32768 # Max AGENTS.md size (32 KiB)
project_doc_fallback_filenames = [] # Alternative instruction filenames
project_root_markers = [".git"] # Project root detection
# ─── Feature Flags ─────────────────────────────────────
# Use `codex features list` for current names/stages/defaults.
[features]
shell_tool = true # Shell command execution (stable)
unified_exec = true # PTY-backed exec (stable)
shell_snapshot = true # Shell env snapshots (stable)
enable_request_compression = true # zstd request compression where supported (stable)
fast_mode = true # Service-tier selection and Fast-tier commands (stable)
goals = true # Goal mode; stable and on by default in v0.133.0+
hooks = true # Lifecycle hooks (stable)
multi_agent = true # Enable multi-agent collaboration tools (stable)
personality = true # Personality selection (stable)
plugins = true # Plugin system (stable)
plugin_hooks = true # Plugin-bundled hooks (stable)
plugin_sharing = true # Workspace plugin sharing (stable)
browser_use = true # In-app browser automation (stable)
browser_use_external = true # Chrome extension browser use (stable)
computer_use = true # macOS Computer Use (stable, plan/region gated)
in_app_browser = true # Shared rendered-page preview (stable)
image_generation = true # Image-generation tool (stable)
guardian_approval = true # Auto-review approval path (stable)
skill_mcp_dependency_install = true # Prompt/install missing skill MCP deps (stable)
tool_suggest = true # Tool/plugin suggestion surface (stable)
workspace_dependencies = true # Workspace dependency discovery (stable)
memories = true # Memories (experimental)
network_proxy = false # Sandboxed networking proxy (experimental)
prevent_idle_sleep = true # Keep machine awake during active turns (experimental)
terminal_resize_reflow = true # Terminal reflow improvements (experimental)
# Removed or deprecated feature names still appear in `codex features list`
# for migration diagnostics. Do not set removed flags such as
# `collaboration_modes`, `request_rule`, `codex_git_commit`,
# `apply_patch_freeform`, `search_tool`, or `js_repl` in new configs.
# ─── Multi-Agent Roles (v0.102.0+) ───────────────────
[agents]
max_threads = 4 # Maximum concurrent agent threads
[agents.explorer]
description = "Read-only codebase navigator"
config_file = "~/.codex/profiles/explorer.toml"
# ─── Notifications ────────────────────────────────────
notify = ["terminal-notifier", "-title", "Codex"] # Command for notifications
# ─── Per-Project Overrides ────────────────────────────
[projects."/absolute/path/to/repo"]
trust_level = "trusted" # Per-project trust override
Profiles
適用於不同工作模式的具名 configuration presets:
# Define profiles in ~/.codex/config.toml
[profiles.fast]
model = "gpt-5.1-codex-mini"
model_reasoning_effort = "low"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
personality = "pragmatic"
[profiles.careful]
model = "gpt-5.4"
model_reasoning_effort = "xhigh"
approval_policy = "untrusted"
sandbox_mode = "read-only"
[profiles.auto]
model = "gpt-5.4"
model_reasoning_effort = "medium"
approval_policy = "never"
sandbox_mode = "workspace-write"
啟用 profile:
codex --profile fast "quick refactor"
codex --profile careful "security audit"
codex -p auto "fix CI"
專家提示:可在 config 頂層使用
profile = "fast"設定預設 profile。每個 session 可用--profile覆寫。
自訂 Model Providers
連接 Azure、AWS Bedrock、本機 models 或 proxy services:
[model_providers.azure]
name = "Azure OpenAI"
base_url = "https://YOUR_PROJECT.openai.azure.com/openai"
wire_api = "responses"
query_params = { api-version = "2025-04-01-preview" }
env_key = "AZURE_OPENAI_API_KEY"
# Built-in amazon-bedrock provider (v0.123.0+, first-class in v0.124.0+)
# AWS SigV4 signing + credential-based auth; AWS profile selectable via the
# nested `aws.profile` field (NOT a top-level `aws_profile` key).
# v0.130.0+ also accepts credentials from `aws login` (the AWS console-login
# flow) — Codex resolves the cached console-login session for the chosen
# profile if static keys are absent.
# v0.140.0+ adds managed Amazon Bedrock API-key authentication, and stores
# CLI and MCP OAuth credentials in encrypted local storage.[^184]
[model_providers.amazon-bedrock]
name = "Amazon Bedrock"
[model_providers.amazon-bedrock.aws]
profile = "default" # any profile from ~/.aws/credentials
# Region/credential resolution otherwise follows the standard AWS chain;
# v0.130.0 added support for `aws login` console-login profiles in addition
# to static access keys and IAM role assumption.[^168]
[model_providers.ollama]
name = "Ollama (Local)"
base_url = "http://localhost:11434/v1"
wire_api = "chat"
警告:
chat/completionswire API(wire_api = "chat")已不建議用於 OpenAI-hosted models,OpenAI 並宣布將於 2026年2月移除。34 本機 providers(Ollama、LM Studio)可能仍接受此格式。OpenAI endpoints 請改用wire_api = "responses"。
使用 --oss flag 搭配本機 models:
codex --oss "explain this function" # Uses default OSS provider
codex --oss --local-provider lmstudio "explain" # Explicit LM Studio
codex --oss --local-provider ollama "explain" # Explicit Ollama
或在 config 中設定:
model_provider = "oss"
oss_provider = "lmstudio" # or "ollama"
Inline Config Overrides
從命令列覆寫任何 config 值:
codex -c model="gpt-5.5" "refactor the API"
codex -c 'sandbox_workspace_write.network_access=true' "install dependencies"
codex -c model_reasoning_effort="xhigh" "debug the race condition"
我該選擇哪個模型?
可用模型(2026 年 4 月)
| 模型 | 輸入 / 總上下文 | 預設推理層級 | 最適用途 |
|---|---|---|---|
| gpt-5.5(Codex) | 400K / 400K | medium |
新旗艦(2026 年 4 月 23 日)——82.7% Terminal-Bench 2.0 SOTA;建議作為大多數 Codex 任務的預設模型。在 API 中:1M 上下文視窗。83 |
| gpt-5.5-pro | 1M / 1M | high |
GPT-5.5 上的最高推理層級(2026 年 4 月 24 日,API 可用)83 |
| gpt-5.4 | 1M / 1M | medium |
前一代旗艦;在 GPT-5.5 於各介面陸續推出期間,仍維持為預設模型 |
| gpt-5.4-mini | 400K / 400K | medium |
子代理工作、較簡單任務——僅佔 GPT-5.4 配額的 30%,速度快 2 倍76 |
| gpt-5.3-codex | 272K / 400K | medium |
編碼專家:複雜的軟體工程任務 |
| gpt-5.3-codex-spark | 128K / 128K | high |
近乎即時的迭代,僅文字(Pro 用戶,Cerebras 合作)67 |
| gpt-5.2-codex | 272K / 400K | medium |
舊版模型;OpenAI 將 gpt-5.4 列為 2026 年 7 月 23 日停用後的替代方案88 |
| gpt-5.1-codex-mini | 272K / 400K | medium |
舊版成本敏感型模型;OpenAI 將 gpt-5.4-mini 列為 2026 年 7 月 23 日停用後的替代方案88 |
GPT-5.5(2026 年 4 月 23 日) 是 OpenAI 為大多數 Codex 任務推薦的選擇:複雜編碼、電腦使用、知識工作與研究流程。4 月 23 日於 Codex CLI / 網頁 / 桌面版開放給 ChatGPT Plus / Pro / Business / Enterprise / Edu / Go;4 月 24 日於 OpenAI API 開放。上下文視窗:Codex 中為 400K,API 中為 1M——Codex 將視窗上限設為 400K,以在訂閱層級之間平衡吞吐量與成本;API 則開放完整的 1M。定價(API):每百萬 token 輸入 $5 / 輸出 $30(為 GPT-5.4 費率的 2 倍;OpenAI 表示在 token 效率改善後,實際漲幅約 20%)。基準測試:82.7% Terminal-Bench 2.0(目前所有公開模型中的 SOTA)、84.9% GDPval(44 種職業)、78.7% OSWorld-Verified、98.0% Tau2-bench Telecom(無提示調校)。OpenAI 在發布前內部使用 GPT-5.5 + Codex 重寫服務基礎設施——使 token 生成速度提升了 20%。83
GPT-5.4 在所有 Codex 介面(CLI、應用程式、IDE 擴充功能、雲端)中仍持續可用。64 確切的模型清單會因帳號與推出進度而異。請查看本地快取:
~/.codex/models_cache.json。棄用說明(2026 年 3 月 11 日):GPT-5.1 模型已不再於 ChatGPT 中提供。現有對話會自動轉移至 GPT-5.3 Instant、GPT-5.4 Thinking 或 GPT-5.4 Pro 繼續進行。GPT-5.1-Codex-Mini 仍可透過 API 與 CLI 用於成本敏感的工作負載。71
免費層說明(2026 年 5 月 5 日):GPT-5.5 Instant 已於 2026 年 5 月 5 日推出至 ChatGPT 免費層。此舉將 GPT-5.5 系列的受眾擴展至付費方案以外,不過 Codex CLI 的存取仍需有效的 Plus / Pro / Business / Enterprise / Edu / Go 訂閱或 API 金鑰。92
GPT-5.4 mini(2026 年 3 月 17 日):GPT-5.4 的較小、較快變體,擁有 400K 上下文,定價為每百萬 token $0.75/$4.50——僅佔 GPT-5.4 配額的 30%。非常適合子代理委派:讓 GPT-5.4 處理規劃與協調,GPT-5.4 mini 子代理則並行處理較窄的子任務(程式碼庫搜尋、檔案審查、文件處理)。76
模型選擇流程圖
Is this a quick fix or simple question?
├─ Yes → gpt-5.1-codex-mini (fastest, cheapest)
└─ No
├─ Do you need real-time pairing speed?
│ ├─ Yes → gpt-5.3-codex-spark (near-instant, Pro only)
│ └─ No
│ ├─ Subagent or parallel subtask (search, review, processing)?
│ │ ├─ Yes → gpt-5.4-mini (30% of GPT-5.4 quota, 2x faster)
│ │ └─ No
│ │ ├─ Pure coding task (refactor, migration, feature build)?
│ │ │ ├─ Yes → gpt-5.3-codex (coding specialist, 272K context)
│ │ │ └─ No → gpt-5.5 (new flagship: 400K context in Codex / 1M in API, 82.7% Terminal-Bench 2.0 SOTA)
└─ Still unsure? → gpt-5.5
推理層級
控制模型在回應前「思考」的程度:
| 層級 | 行為 | 使用時機 |
|---|---|---|
minimal |
最低限度的推理(僅限 GPT-5 模型) | 瑣碎任務、快速查詢 |
low |
簡短推理 | 標準編碼任務、格式化 |
medium |
平衡(預設) | 大多數開發工作 |
high |
延伸推理 | 複雜錯誤、架構設計 |
xhigh |
最大推理 | 安全稽核、深度分析 |
支援的層級因模型而異。
minimal僅適用於 GPT-5 模型。並非所有模型都支援每個層級。
codex -c model_reasoning_effort="xhigh" "find the race condition"
專家提示:相同提示下,
xhigh推理消耗的 token 可能是medium的 3-5 倍。請保留給確實困難、值得多花心力思考的問題。
TUI 快捷推理控制(v0.124.0+)。85 在互動式 TUI 工作階段中,Alt+, 將推理降低一級,Alt+. 則提高一級——當工作階段中遇到困難問題,需要臨時將 medium → high → xhigh 提升,卻不想動用 /effort 或 -c 時,這非常實用。當您在工作階段中接受模型升級時,推理層級會重設為新模型的預設值,而不會延續先前的層級。
模型切換
使用 /model 斜線命令在工作階段中切換模型,或透過 --model / -m 為單次執行設定:
codex -m gpt-5.3-codex-spark "pair with me on this component"
## Codex 的費用是多少?
另請參閱[模型選擇](#which-model-should-i-choose)了解各模型能力,以及[決策框架](#decision-frameworks)了解如何依任務挑選合適的模型。
### 透過 ChatGPT 方案存取
Codex 的可用性取決於您的 ChatGPT 方案與組織設定:[^61]
| 方案 | 價格 | Codex 存取權 | 速率限制(5 小時區間) |
|------|-------|-------------|----------------------------|
| **Free / Go** | $0 / $5 | 限時推廣存取 | 低 |
| **Plus** | $20/月 | 本機 CLI + 雲端任務(2 倍速率限制) | 本機 45-225 則訊息、雲端 10-60 個任務 |
| **Pro** | $200/月 | 優先處理、GPT-5.3-Codex-Spark(2 倍速率限制) | 本機 300-1500 則訊息、雲端 50-400 個任務 |
| **Business** | $25/使用者/月(年繳 $20) | 標準席次包含 Codex 與 ChatGPT、SAML SSO | 依方案限制速率 |
| **Business(僅 Codex 席次)** | 用多少付多少 | 以 Token 計費,無固定席次費用,無速率限制 | 以 Token 計費 |
| **Enterprise / Edu** | 聯絡業務 | 自訂配額、管理員控制、稽核日誌,提供僅 Codex 席次 | 隨合約規模調整 |
| **API Key** | 依用量計費 | CLI、SDK、僅限 IDE(無雲端功能) | 以 Token 計費 |
> **2026 年 4 月定價更新:** Business 年繳價格由 $25 調降為每席次每月 $20。Business 與 Enterprise 工作空間現可選用「僅 Codex 席次」並採用多少付多少的計費方式——無固定席次費用,依 Token 用量計費。[^84] 付費方案的 2 倍速率限制推廣(自 2026 年 2 月 Desktop App 推出時開始)持續有效。[^17]
>
> **2026 年 5 月用量上限提升(至 2026 年 5 月 31 日止):** Plus 方案上的 Codex 以 **25 倍 5 小時上限**運作(標準提升為 20 倍),且**每月 $100 級距加倍**,皆適用於同一期間。請善用這段期間執行更長的雲端任務批次,或進行更高吞吐量的 Agent 執行,而不會撞上平常的 5 小時上限。[^166]
### 點數費用
Codex 操作會從方案配額中扣除點數:
| 操作 | 約略點數 | 備註 |
|-----------|----------------|-------|
| 本機訊息(GPT-5.3-Codex) | ~5 | 標準旗艦模型 |
| 本機訊息(GPT-5.1-Codex-Mini) | ~1 | 相同點數預算下訊息量為 4 倍 |
| 雲端任務 | ~25 | 在 OpenAI 託管環境中執行 |
| 程式碼審查(每個 PR) | ~25 | 透過 `/review` 或雲端審查 |
> Enterprise 與 Edu 方案的點數隨合約配額而定。請於 TUI 中執行 `/status` 查看目前用量。
### API 計費
透過 API 使用 Codex 時,OpenAI 會依所選模型套用標準 OpenAI API 定價,按 Token 計費(並適用任何相關的 prompt 快取折扣)。最新費率請參閱[官方 API 定價頁面](https://openai.com/api/pricing/)。[^21]
### 成本最佳化策略
1. **善用 profiles**:為例行任務建立 `fast` profile,搭配 `gpt-5.1-codex-mini` 與 `model_reasoning_effort = "low"`
2. **保留高推理層級**:僅在面對真正困難的問題時才使用 `xhigh`,因其消耗的 Token 是 3-5 倍
3. **使用 `--ephemeral`**:在 CI/CD 中跳過 session 持久化以降低額外負擔
4. **盡量精簡推理摘要**:當不需要解釋時,將 `model_reasoning_summary` 設為 `"none"`
5. **以 exec 模式批次執行**:`codex exec` 可避免 TUI 在自動化流程中產生的負擔
6. **監控用量**:於 TUI 中執行 `/status` 並查看組織計費儀表板
### 實際成本範例
常見任務的代表性 API 成本(gpt-5.3-codex 採標準定價、中等推理層級):
| 任務 | 輸入 Token | 輸出 Token | 約略費用 |
|------|-------------|---------------|-------------|
| 解釋一個 500 行的模組 | ~15K | ~2K | ~$0.25 |
| 修復失敗的測試(1-2 個檔案) | ~30K | ~5K | ~$0.50 |
| 新增一個附帶測試的 API endpoint | ~60K | ~15K | ~$1.10 |
| 重構驗證模組(10 個檔案) | ~120K | ~30K | ~$2.25 |
| 透過 `codex exec` 進行完整 repo 稽核 | ~200K | ~20K | ~$3.00 |
| 雲端任務:分類 20 個開放議題 | ~250K | ~40K | ~$4.50 |
> 費用會因推理層級、快取與對話長度而有所不同。例行任務使用 `gpt-5.1-codex-mini` 可降低約 40-60% 的成本。已快取的輸入 Token 將以折扣價計費。
### 隱性 Token 負擔
每次工具呼叫都會在您可見的 prompt 之外增加額外 Token:
| 負擔來源 | 約略成本 |
|-----------------|-------------|
| 系統 prompt + AGENTS.md | 每輪 ~2-5K Token(首次載入後即會被快取) |
| 工具定義 | 每個已註冊工具 ~500 Token |
| 檔案讀取(`@file`) | 完整檔案內容的 Token 數 |
| MCP 工具定義 | 每個已連線的 server ~200-500 Token |
| 推理軌跡 | 不固定;`xhigh` 可能增加 3-5 倍負擔 |
> **專家提示:** 透過 TUI 的 `/status` 監控實際用量。Token 計數涵蓋所有額外負擔,而非僅是您可見的訊息。若費用出乎意料,請檢查連接了多少個 MCP servers——每一個都會在每次 API 呼叫中加入工具定義。
### 團隊成本管理
| 團隊規模 | 建議設定 | 預期每月成本 |
|-----------|-------------------|----------------------|
| 獨立開發者 | 預設模型、`medium` 推理層級 | $20-80 |
| 小型團隊(3-5 人) | 使用 profiles(`fast`/`careful`)、透過 `codex exec` 進行程式碼審查 | $200-500 |
| 中型團隊(10-20 人) | Enterprise 方案、`requirements.toml` 限制、CI 整合 | $1,000-3,000 |
| 大型組織(50 人以上) | 含管理員控制、稽核日誌與配置預算的 Enterprise | 客製化定價 |
團隊成本控制策略:
- **設定 `requirements.toml`** 以在組織內全面強制模型與推理層級上限
- **CI/CD 採用 `gpt-5.1-codex-mini`**——自動化管線鮮少需要最高推理層級
- **以 profile 為基礎進行預算控管**——分別定義 `ci`、`review` 與 `dev` profiles,並設定合適的成本上限
- **透過 OpenTelemetry 監控**——企業部署可將用量遙測資料匯出至既有的可觀測性平台
## 決策框架
### 何時使用各介面
| 情境 | 最佳介面 | 原因 |
|----------|-------------|-----|
| 快速修復 bug | CLI | 快速、聚焦、可指令稿化 |
| 多檔案重構 | CLI 或 App | CLI 提供確定性的 patch;App 提供視覺化 diff 檢視 |
| 探索陌生程式碼 | CLI | 終端機可組合性、grep/find 整合 |
| 平行工作流 | Desktop App | Worktree 隔離、多任務管理 |
| 主動編輯檔案 | IDE Extension | 行內編輯、緊湊的編譯測試循環 |
| 長時間執行的遷移 | Cloud | 獨立執行,完成後建立 PR |
| CI/CD 自動化 | `codex exec` | 非互動式、JSON 輸出、可指令稿化 |
| 程式碼審查 | CLI 或 App | `/review` 指令搭配預設組態 |
| 團隊上手 | Desktop App | 視覺化、引導式、較少需要終端機知識 |
### 何時使用各 Sandbox 模式
| 情境 | 模式 | 核准 | 原因 |
|----------|------|----------|-----|
| 探索未知程式碼 | `read-only` | `untrusted` | 最高安全性,不會破壞任何東西 |
| 日常開發 | `workspace-write` | `on-request` | 速度與安全性的良好平衡 |
| 受信任的自動化 | `workspace-write` | `never` | 快速、不中斷、有 sandbox 隔離 |
| 系統管理 | `danger-full-access` | `on-request` | 需要完整存取權但仍需人工核准 |
| CI/CD 流程 | `workspace-write` | `never` | 自動化,並隔離至工作區範圍 |
### 何時使用各推理層級
| 任務類型 | 推理層級 | 模型 | Profile |
|-----------|-----------|-------|---------|
| 格式化、lint | `low` | `gpt-5.1-codex-mini` | `fast` |
| 標準編碼 | `low`-`medium` | `gpt-5.3-codex` | 預設 |
| 複雜除錯 | `high` | `gpt-5.3-codex` | `careful` |
| 安全稽核 | `xhigh` | `gpt-5.3-codex` | `careful` |
| 快速原型開發 | `low` | `gpt-5.3-codex-spark` | `fast` |
| 遷移/重構 | `medium`-`high` | `gpt-5.5` 或 `gpt-5.4` | 預設 |
### Plan Mode 與直接執行
```text
Will Codex need to change more than 3 files?
│
├── YES → Use Plan Mode (/plan)
│ Codex designs the approach BEFORE making changes.
│ You review and approve the plan.
│ Best for: refactors, new features, migrations
│
└── NO → Is the change well-defined?
│
├── YES → Direct execution
│ Just describe the task. Codex executes immediately.
│ Best for: bug fixes, small features, test additions
│
└── NO → Use Plan Mode (/plan)
Let Codex explore and propose an approach first.
Best for: unfamiliar codebases, ambiguous requirements
Steer Mode:Enter 與 Tab
| 情況 | 使用 Enter | 使用 Tab |
|---|---|---|
| Codex 即將犯錯 | 立即傳送修正 | |
| 您有後續任務 | 排入目前工作之後執行 | |
| Codex 選錯檔案 | 立即傳送重新導向 | |
| 您想擴增工作範圍 | 排入新增項目 | |
| 緊急優先順序變更 | 立即傳送新優先順序 | |
| 非關鍵性脈絡 | 排入佇列——不急 |
經驗法則:Enter = 「停下來,現在聽這個。」Tab = 「您忙完之後,也做這個。」
Desktop App 與 CLI
How do you prefer to work?
│
├── Terminal-first → Use CLI
│ │
│ ├── Single focused task → codex (interactive TUI)
│ ├── Scripted automation → codex exec (non-interactive)
│ └── Quick one-shot → codex exec "prompt" -o result.txt
│
└── Visual/multi-project → Use Desktop App
│
├── Multiple parallel tasks → Multi-thread with worktree isolation
├── Visual diff review → Built-in Git diff viewer
├── Scheduled automation → Automations tab
└── Voice-driven → Ctrl+M for voice dictation
| 功能 | CLI | Desktop App |
|---|---|---|
| 互動式工作階段 | 支援 | 支援 |
| 平行 agent | 手動(多個終端機) | 內建(worktree 隔離) |
| Diff 檢視 | /diff(文字) |
視覺化行內 diff |
| 自動化 | Cron + codex exec |
GUI 排程器 |
| 語音輸入 | 不支援 | 支援(Ctrl+M) |
| CI/CD 整合 | codex exec + GitHub Action |
不支援 |
| 工作階段同步 | 支援 | 支援(與 CLI 共用) |
該選哪個 Profile?
依任務挑選預先設定好的 profile:
| 任務類型 | Profile | 主要設定 |
|---|---|---|
| 快速問答、格式化 | fast |
model = "gpt-5.1-codex-mini"、model_reasoning_effort = "low" |
| 日常開發 | (預設) | model = "gpt-5.3-codex"、model_reasoning_effort = "medium" |
| 架構、安全 | careful |
model = "gpt-5.3-codex"、model_reasoning_effort = "xhigh" |
| 即時結對 | pair |
model = "gpt-5.3-codex-spark"、model_reasoning_effort = "high" |
| CI/CD 自動化 | ci |
model = "gpt-5.1-codex-mini"、model_reasoning_effort = "low"、sandbox_mode = "workspace-write" |
config.toml 設定範例:
# Default profile
profile = "default"
[profiles.fast]
model = "gpt-5.1-codex-mini"
model_reasoning_effort = "low"
[profiles.careful]
model = "gpt-5.3-codex"
model_reasoning_effort = "xhigh"
[profiles.pair]
model = "gpt-5.3-codex-spark"
model_reasoning_effort = "high"
[profiles.ci]
model = "gpt-5.1-codex-mini"
model_reasoning_effort = "low"
sandbox_mode = "workspace-write"
依工作階段切換 profile:codex --profile careful
Sandbox與Approval System如何運作?
Codex採用雙層安全模型,將技術上可行的事與Codex何時要求人工核准分開處理。此方法與Claude Code的權限系統有根本差異;Codex會在OS kernel層級強制執行限制。5另請參閱Enterprise Deployment,了解管理員可在整個組織強制套用的requirements.toml限制。
第1層:Sandbox(可執行的範圍)
Sandbox會透過OS原生機制控制檔案系統與網路存取:
| 模式 | 檔案存取 | 網路 | 實作 |
|---|---|---|---|
read-only |
全域唯讀 | 封鎖 | 最嚴格;變更需要明確核准 |
workspace-write |
工作區與/tmp可讀寫 |
預設封鎖 | 一般開發;安全預設值 |
danger-full-access |
完整機器存取 | 啟用 | 最大能力;請謹慎使用(denylist-only變體已於v0.121.0移除,現在是二元開關)82 |
平台特定的強制執行方式:
- macOS:透過
sandbox-exec使用Apple的Seatbelt框架,依模式在執行階段編譯設定檔,並由kernel強制執行6。自v0.121.0起,macOS sandbox設定檔可將特定Unix sockets列入allowlist(例如docker.sock、編輯器IPC sockets),且預設不再封鎖私人DNS解析。82 - Linux:以Landlock限制檔案系統,並以seccomp過濾syscall。獨立的輔助程序(
codex-linux-sandbox)提供縱深防禦隔離。5Bubblewrap(bwrap)會隨附並編譯為Linux建置的一部分(在v0.100.0由選用升級為內建)7。v0.117.0改善了舊版發行版與舊式kernel設定上的sandbox可靠性。75v0.129.0強化了Linux上的sandbox啟動流程,並將隨附的Bubblewrap升級至0.11.2,納入上游安全修補;v0.130.0則進一步強化啟動流程。8991 - Windows:使用受限token的原生sandbox(在v0.100.0由實驗性升級)。也支援WSL(繼承Linux Landlock與seccomp)。v0.117.0包含受限token sandbox改進,以提升程序隔離。75v0.130.0讓sandbox使用者可存取desktop runtime binary cache,使Windows sandbox能為workspace-sandbox使用者可靠解析runtime binaries。91
為什麼這很重要:不同於以容器為基礎的sandboxing(Docker),OS層級sandboxing更快、更輕量,也更難逃逸。kernel會在Codex看到system call之前就先強制執行限制。
安全修補:
- zsh-fork sandbox繞過(v0.106.0):修正了透過zsh fork執行shell時可能繞過sandbox限制的漏洞。60若您仍使用更早版本,請立即升級。
- 輸入大小上限(v0.106.0):Codex現在會強制執行約100萬字元的輸入上限,避免過大的payload導致停滯。60
- 安全devcontainer設定檔(v0.121.0):針對Docker devcontainers新增強化的客戶設定檔,在容器內使用Bubblewrap進行sandboxing。支援WSL2;明確拒絕WSL1(Bubblewrap與WSL1的kernel shim不相容)。82
- Guardian review與hooks(v0.121.0):Guardian review工作階段期間會停用hooks,因此pre/post-tool hooks無法干擾Guardian subagent的決策。82如果您依賴hooks做記錄或驗證,請注意Guardian review會略過它們;若需要完整稽核軌跡,請改用app-server可觀測性。
- Linux /dev檔案系統(v0.105.0):Linux上的sandboxed commands現在會取得最小化的/dev檔案系統,改善需要device nodes之工具的相容性。61
ReadOnlyAccess政策(v0.100.0+):這是一種可設定的政策形狀,用於精細控制讀取權限。即使在workspace-write模式下,也可用它限制Codex能讀取哪些目錄:
[sandbox_workspace_write]
read_only_access = ["/etc", "/usr/local/share"] # Only these paths readable outside workspace
第2層:Approval Policy(何時詢問)
Approval policy決定Codex何時暫停並要求人工確認:
| 政策 | 行為 | 使用情境 |
|---|---|---|
untrusted |
自動執行安全讀取;其他一律提示 | 最高信任門檻;不熟悉的repos |
on-request |
sandbox內核准;越界時提示 | 預設;良好平衡 |
never |
完全不提示 | CI/CD、可信任自動化 |
on-failure仍出現在部分較舊範例與相容路徑中,但目前OpenAI設定文件將其標記為已棄用。互動式執行建議使用on-request;已具備外部安全邊界的非互動式執行,則使用never。87
不同的Approval IDs(v0.104.0+)
Codex現在會為多步驟shell執行中的每個command指派不同的approval ID。這表示核准會更精細;核准序列中的一個command,不會自動核准同一shell invocation裡後續的command。49
彈性的Approval Controls(v0.105.0+)
Approval流程現在支援額外sandbox權限與精細拒絕:61
- 額外sandbox權限:當command需要超出目前sandbox模式的存取權時,Codex可以要求特定的額外權限,而不必要求完整切換模式
- 精細拒絕:可帶著回饋拒絕個別tool calls,讓Codex調整方法,而不是單純重新嘗試相同command
Runtime Permission Requests(v0.113.0+)
Codex現在內建request_permissions工具,讓模型能在執行階段要求額外權限。69當模型遇到需要提升存取權的任務時,可以透過TUI approval流程正式要求特定權限(檔案系統路徑、網路存取等),而不是默默失敗,或要求使用者以不同flags重新啟動。
Permission Profiles(v0.113.0+,於v0.128.0與v0.133.0擴充)
Permission profiles會將檔案系統與網路sandbox政策拆分成具名、可重複使用的區段。將default_permissions設定為內建profile,例如:read-only、:workspace,或指向自訂的[permissions.<name>]表格。87v0.133.0將profiles提升為受管理的介面:list APIs會公開可用profile中繼資料,profiles可彼此繼承,受管理的requirements.toml可宣告權限需求,active profiles會在執行階段重新整理,Windows sandbox設定也改為使用已解析的profile,而非另一套臨時政策。98
default_permissions = "project-safe"
[permissions.project-safe.filesystem]
"/usr/local" = "read"
glob_scan_max_depth = 3
[permissions.project-safe.filesystem.":project_roots"]
"." = "write"
"**/*.env" = "none"
[permissions.project-safe.network]
enabled = true
mode = "limited"
[permissions.project-safe.network.domains]
"api.github.com" = "allow"
"registry.npmjs.org" = "allow"
對於即使專案根目錄可寫也不應被讀取的敏感檔案與globs,請使用none。針對一次性的command例外,建議使用rules,而不是大幅擴張profile。87
舊版--full-auto指引
較舊的指南將--full-auto描述為以下設定的便利別名:
codex --sandbox workspace-write --ask-for-approval on-request
在v0.128.0中,release notes將--full-auto標記為已棄用,而目前的CLI help已不再將它列於互動式執行。請改用上方明確flags,或使用具名permissions profile。86
Sandbox可靠性(v0.129.0):Linux sandbox啟動強化可減少慢速檔案系統或symlinked checkouts上的競爭狀況;Windows sandbox可靠性改進則處理了長時間執行期間的多個邊界案例當機;隨附的Bubblewrap也升級至0.11.2,納入上游安全修補。不需要變更設定。請執行
codex update取得這些更新。89
建議設定
日常開發(安全預設值):
sandbox_mode = "workspace-write"
approval_policy = "on-request"
進階使用者(完整存取,人工介入):
sandbox_mode = "danger-full-access"
approval_policy = "untrusted"
這個組合是社群建議的「sweet spot」:具備最大能力,但每個command都需要核准。8
CI/CD自動化:
sandbox_mode = "workspace-write"
approval_policy = "never"
使用Guardian Subagent的Smart Approvals(v0.115.0+)
Smart Approvals可將review requests透過guardian subagent路由,而不是每個action都要求人工核准。guardian工作階段會在多次核准之間保留,以重用prompt cache並避免啟動成本。每次review都會取得乾淨的history(先前決策不會洩漏到後續review)。73
在config.toml中設定reviewer:
approvals_reviewer = "guardian_subagent" # "user" (default) or "guardian_subagent"
這特別適合CI/CD工作流程:您可以取得帶有推理的自動化review,而不是一律套用approval_policy = "never"。
啟用網路存取
Codex在workspace-write模式下預設封鎖網路存取。需要時可啟用:
# Per-run
codex -c 'sandbox_workspace_write.network_access=true' "install the packages"
# In config.toml
[sandbox_workspace_write]
network_access = true
writable_roots = ["/path/to/extra/dir"] # Additional writable directories
exclude_slash_tmp = false # Prevent /tmp from being writable
exclude_tmpdir_env_var = false # Prevent $TMPDIR from being writable
WebSocket Proxy支援(v0.104.0+)
對於透過proxy路由WebSocket流量的企業環境,Codex現在支援WS_PROXY與WSS_PROXY環境變數:49
export WSS_PROXY="https://proxy.corp.example.com:8443"
codex "update the README"
這些變數補足既有的HTTPS_PROXY與SOCKS5 proxy支援(v0.93.0+),涵蓋所有傳輸層。
測試Sandbox
在信任sandbox之前,請先驗證其行為:
codex sandbox macos --permissions-profile :workspace -- ls /etc/passwd # macOS test
codex sandbox linux --permissions-profile :workspace -- cat /etc/shadow # Linux test
如果sandbox正常運作,在workspace-scoped profile下,兩個commands都應該因permission denied錯誤而失敗。若任一command成功,則需要進一步檢查您的sandbox設定。
AGENTS.md 如何運作?
AGENTS.md 是 Codex 的專案指令系統,也是一項開放標準9,目前由 Linux Foundation 的 Agentic AI Foundation 治理。Codex、Cursor、Copilot、Amp、Jules(Google)、Gemini CLI、Windsurf、Cline、Aider、Zed、Factory、RooCode,以及 60,000 多個開放原始碼專案皆支援此標準。它定義 Codex 在特定儲存庫或目錄中的行為方式。可重複使用的專業能力套件,請參閱 Skills;它們可與 AGENTS.md 互補。
探索階層
Codex 會在工作階段開始時走訪目錄樹,建立指令鏈:
- 全域(
~/.codex/):AGENTS.override.md>AGENTS.md - 專案(從 git 根目錄到目前目錄):每一層都會檢查
AGENTS.override.md>AGENTS.md> 備援檔名 - 合併:檔案會從根目錄往下串接;距離目前位置越近的檔案,會越晚出現在 prompt 中,並覆寫較早的指引
~/.codex/AGENTS.md ← Global defaults
└─ /repo/AGENTS.md ← Project-wide rules
└─ /repo/services/AGENTS.md ← Service-specific rules
└─ /repo/services/payments/
AGENTS.override.md ← Overrides everything above for this dir
優秀 AGENTS.md 的要件
根據 Codex 本身的直接指引與社群模式10:
建議:
- 具體明確:"Use rg --files for discovery" 勝過 "search efficiently"
- 定義完成條件:什麼才算「完成」?(測試通過、lint 乾淨等)
- 納入命令:建置、測試、lint、格式化(精確呼叫方式)
- 依任務組織:程式撰寫、review、release、incident/debug 區段
- 定義升級處理:受阻或遇到非預期狀態時該怎麼做
避免: - 傾倒整份風格指南,卻沒有可執行規則 - 使用含糊指令(「小心處理」、「最佳化」) - 混合彼此衝突的優先順序(速度 + 完整驗證 + 沒有執行時間預算) - 撰寫散文式文件(AGENTS.md 是操作政策,不是 README)
範例:Production AGENTS.md
# Repository Guidelines
## Build, Test, and Development Commands
- Run API (dev): `python3 -m uvicorn main:app --reload`
- Install deps: `pip install -r requirements.txt`
- Lint: `python3 -m ruff check .` (auto-fix: `--fix`)
- Format: `python3 -m ruff format .`
- Tests: `python3 -m pytest -v`
- Coverage: `python3 -m pytest --cov=app --cov-report=term-missing`
## Coding Style & Naming Conventions
- Python 3.11+. Type hints on all functions.
- Ruff enforced: 88-char lines, double quotes, spaces for indent.
- Naming: modules `snake_case.py`, classes `PascalCase`, functions `snake_case`.
## Commit & Pull Request Guidelines
- Conventional Commits: `feat:`, `fix:`, `docs:`, `refactor:`, `chore:`, `test:`
- Commits should be small and focused.
- PRs must include: description, test plan, and screenshots for UI changes.
## Security
- Never commit secrets. Use `.env` for local config.
- Validate all external API calls with proper error handling.
Agent 工作階段中的秘密處理
請將 Codex 可見的歷史紀錄視為安全攻擊面,而不只是原始程式碼。Codex release notes 記載了 shell 快照與環境變數遮蔽的相關工作,memory 系統也會掃描 memory 寫入中的秘密;但這些防護並不代表命令輸出、工作階段逐字稿、shell 快照、本機日誌或輔助指令碼就是列印憑證的安全位置。375595
操作規則很簡單:不要列印秘密讓模型檢視;將輔助憑證保留在需要環境變數的設定中;稽核時,區分可執行原始碼、文件、產生的快取、工作階段逐字稿、shell 快照、日誌,以及刻意設置的秘密儲存區;當出現高信心的秘密格式時,遮蔽本機歷史紀錄;並且只有在手動衛生流程已經證實可靠後,才提升預防性 hooks。公開可分享的教訓是攻擊面地圖與驗收標準,而不是私人 token 值、精確路徑或偵測器內部細節。95
Override 機制
任何目錄層級的 AGENTS.override.md 都會取代該作用範圍的一般 AGENTS.md。適用於:
- Release 凍結:「不新增功能,只修正問題」
- Incident 模式:「所有變更都必須由 on-call review」
- 暫時性強化:「本 sprint 不更新相依套件」
設定
# Custom fallback filenames (in addition to AGENTS.md)
project_doc_fallback_filenames = ["TEAM_GUIDE.md", ".agents.md"]
# Increase max size for large instruction files
project_doc_max_bytes = 65536 # 64 KiB (default: 32 KiB)
Scaffold 產生
codex # Launch TUI
/init # Generate AGENTS.md scaffold
或驗證您的指令鏈:
codex --ask-for-approval never "Summarize your current instructions"
Hooks
Codex 在 v0.99.0(AfterAgent)與 v0.100.0(AfterToolUse)導入 hooks,接著在 v0.114.0 加入實驗性 hooks engine,提供 SessionStart 與 Stop events。70 截至 v0.124.0(2026年4月23日),hooks 已穩定。85 現在可直接在 config.toml 與 requirements.toml 內嵌設定,不再需要獨立的 hook scripts 檔案;它們也會觀察 MCP tools,以及 apply_patch 和長時間執行的 Bash 工作階段。此系統如今涵蓋工作階段生命週期與 tool 層級自動化,補上了與 Claude Code hook model 之間的差距。
可用的 Hook Events
| Event | 觸發時機 | 新增版本 |
|---|---|---|
SessionStart |
每個工作階段開始時觸發一次;hook stdout 會在第一輪之前注入為啟動 context | v0.114.0 [EXPERIMENTAL] |
Stop |
工作階段結束時 | v0.114.0 [EXPERIMENTAL] |
AfterAgent |
agent 完成一個完整回合後 | v0.99.0 |
AfterToolUse |
每次個別 tool call 完成後 | v0.100.0 |
UserPromptSubmit |
使用者 prompt 執行前;可在其進入歷史紀錄前封鎖或補充 prompt | v0.116.0 [EXPERIMENTAL] |
Hook 設定
Hooks 設定於 .codex/config.toml:
[[hooks]]
event = "AfterToolUse"
command = "echo 'Tool completed' >> /tmp/codex-log.txt"
[[hooks]]
event = "SessionStart"
command = "echo 'Current date: $(date +%Y-%m-%d)'"
SessionStart hook 的 stdout 會送入模型 context,因此很適合在工作階段開始時注入動態資訊(日期、branch 名稱、環境變數)。
複製 Claude Code Hook 模式
若從 Claude Code 遷移,可用以下方式達成類似自動化:
| Claude Code Pattern | Codex Alternative |
|---|---|
PreToolUse 檔案封鎖 |
AGENTS.md 指令 + sandbox read-only mode |
PostToolUse linting |
執行 linter 的 AfterToolUse hook |
SessionStart context 注入 |
搭配 stdout 注入的 SessionStart hook(v0.114.0) |
Stop 通知 |
搭配通知命令的 Stop hook(v0.114.0) |
SubagentStop 通知 |
搭配通知 script 的 AfterAgent hook |
| 非同步 hooks | 尚未支援;背景工作請使用 Cloud tasks |
專家提示:截至 v0.124.0(2026年4月23日),hooks engine 已穩定。新的 hook events 仍會隨 release 推出,請查看 Codex changelog。
TUI 內建 hook 瀏覽器(v0.129.0):在 TUI 中執行
/hooks,即可探索可用 hooks、查看目前啟用項目,並在不編輯config.toml的情況下切換個別 hooks。當您排查行為異常的 plugin-bundled hook,或需要在專注編輯工作階段暫時停用AfterToolUselinter 時,這會很有幫助。89
什麼是MCP(Model Context Protocol)?[EXPERIMENTAL]
MCP透過連接外部工具與服務,擴充 Codex 的能力。codex mcp命令群組目前標示為實驗性,命令與設定格式可能會在不同版本之間變更。Codex 支援兩種傳輸類型:STDIO(本機程序)與 Streamable HTTP(遠端伺服器)。11
v0.121.0 MCP變更:工具現在會以命名空間註冊,因此清單中的工具名稱會顯示為
<server>:<tool>,而不是裸名稱;若有任何 scripts 或 prompts 會對未限定的工具名稱執行 grep,請同步更新。新的supports_parallel_tool_calls旗標已串接至內含的MCP,讓宣告支援的伺服器能夠平行執行。沙盒狀態中繼資料現在會透過MCP工具中繼資料流動,讓伺服器可調整行為(例如在 read-only sandbox 下執行時提出警告)。自訂的codex/sandbox-state請求已移除;請改用中繼資料路徑。MCP Apps 推出的第 3 階段也在此版本落地,並加入工具呼叫支援;對使用延遲呼叫模式的伺服器,現在也支援扁平化的延遲工具呼叫。82
設定MCP伺服器
STDIO 伺服器(本機程序):
# In ~/.codex/config.toml or .codex/config.toml
[mcp_servers.context7]
enabled = true
required = true # Fail startup if unavailable
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
env = { "MY_VAR" = "value" } # Static env vars
env_vars = ["PATH", "HOME"] # Forward host env vars
cwd = "/path/to/project" # Optional working directory
startup_timeout_sec = 10
tool_timeout_sec = 60
enabled_tools = ["search", "summarize"] # Tool allowlist
disabled_tools = ["slow-tool"] # Tool denylist
HTTP 伺服器(遠端):
[mcp_servers.figma]
enabled = true
url = "https://mcp.figma.com/mcp"
bearer_token_env_var = "FIGMA_OAUTH_TOKEN"
http_headers = { "X-Figma-Region" = "us-east-1" }
env_http_headers = { "X-Org-Id" = "FIGMA_ORG_ID" } # Headers from env vars
startup_timeout_sec = 10
tool_timeout_sec = 60
CLI管理
codex mcp add context7 -- npx -y @upstash/context7-mcp
codex mcp add context7 --env API_KEY=... -- npx -y @upstash/context7-mcp # With env vars
codex mcp add figma --url https://mcp.figma.com/mcp --bearer-token-env-var FIGMA_OAUTH_TOKEN
codex mcp list # List all configured servers
codex mcp list --json # JSON output
codex mcp get context7 # Show server config
codex mcp get context7 --json # JSON output
codex mcp login <server> # OAuth flow for HTTP servers
codex mcp logout <server> # Remove OAuth credentials
codex mcp remove <server> # Delete server definition
工作階段內:/mcp會顯示啟用中的伺服器與可用工具。/mcp verbose(v0.123.0+)84會回傳完整的伺服器診斷、資源與資源範本;當伺服器載入失敗,或工具未出現在預期位置時特別實用。一般的/mcp則維持快速。
Plugin MCP載入(v0.123.0+)同時接受標準mcpServers結構描述,以及.mcp.json中的頂層伺服器對應,因此依任一慣例撰寫的 plugins 都能順利載入。84
將 Codex 作為MCP伺服器執行
Codex 可以將自身公開為MCP伺服器,用於多 agent 編排:12
codex mcp-server # Start as MCP server (stdio transport)
此伺服器公開兩個工具:
1. codex():使用 prompt、sandbox、model 與 approval 參數啟動新工作階段
2. codex-reply():使用threadId與 prompt 繼續既有工作階段
搭配 Agents SDK(Python)使用:
from agents import Agent, Runner
from agents.mcp import MCPServerStdio
async with MCPServerStdio(
name="Codex CLI",
params={"command": "npx", "args": ["-y", "codex", "mcp-server"]},
client_session_timeout_seconds=360000,
) as codex_mcp_server:
agent = Agent(name="Developer", mcp_servers=[codex_mcp_server])
result = await Runner.run(agent, "Fix the failing tests")
重要的MCP伺服器
| Server | Purpose | Install |
|---|---|---|
| Context7 | 最新的函式庫文件 | npx -y @upstash/context7-mcp |
| Figma | 存取設計檔案 | HTTP: https://mcp.figma.com/mcp |
| Playwright | 瀏覽器自動化 | npx -y @anthropic/mcp-playwright |
| Sentry | 錯誤監控 | HTTP: https://mcp.sentry.dev/mcp |
| GitHub | 儲存庫操作 | npx -y @anthropic/mcp-github |
實務模式
模式 1:具備情境感知的開發——將 Context7 與您的框架文件搭配使用,讓 Codex 始終具備最新的API參考資料:
[mcp_servers.context7]
enabled = true
required = true
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
模式 2:輸出限制——MCP工具回應預設會在約 25K 字元處截斷。對於會回傳大型 payload 的工具(資料庫查詢、log 擷取),請使用enabled_tools限制為特定工具,讓回應聚焦。
模式 2a:多模態工具輸出(v0.107.0)——自訂工具現在可以在文字之外,同時回傳多模態輸出(圖片、豐富內容)。這讓會產生視覺成果的工具——例如螢幕截圖、圖表、chart renders——可以直接傳給模型進行分析。62
模式 3:企業MCP治理——透過requirements.toml鎖定開發人員可使用哪些MCP伺服器:
# In /etc/codex/requirements.toml — only approved servers allowed
[mcp_servers.approved-internal]
identity = { command = "npx @company/internal-mcp" }
任何未符合requirements.toml中 identity 的伺服器,都會在啟動時遭到封鎖。完整政策設定請參閱企業部署。
Code Mode [EXPERIMENTAL]
Code mode(v0.114.0)透過將 agent 的範圍限制在以程式碼為核心的操作,提供更隔離的 coding workflow。70啟用後,agent 會專注於讀取、撰寫與測試程式碼,不進行更廣泛的系統互動。
截至 v0.139.0,code mode 可以直接呼叫獨立 web search,包含從巢狀JavaScript工具呼叫中呼叫,並接收純文字結果。因此,code-mode 流程可以在不離開沙盒化 coding context 的情況下擷取即時資訊。105
此功能為實驗性。請查看 release notes 以取得更新。
JavaScript REPL Runtime [REMOVED]
Codex v0.100.0 新增了實驗性的JavaScript REPL runtime(js_repl),v0.106.0 則透過/experimental介面推廣。60該指引現在已屬歷史內容。在 v0.128.0 中,release changelog 包含「Remove js_repl feature」,目前的功能清單也將js_repl與js_repl_tools_only標示為已移除。86
請勿在新 config 中加入features.js_repl = true。需要可重複執行的邏輯時,請使用 shell commands、已納入版本控制的 scripts、MCP工具,或具備scripts/目錄的 Codex skill。
Skills 是什麼?
Skills 是可重複使用、依任務而定的能力套件,Codex 會按需載入。它們遵循開放式 agent skills 標準。13
Skill 結構
my-skill/
SKILL.md (required: instructions)
scripts/ (optional: executable scripts)
references/ (optional: reference docs)
assets/ (optional: images, icons)
agents/openai.yaml (optional: metadata, UI, dependencies)
探索位置
Codex 會將使用者安裝的 skills 儲存在 $CODEX_HOME/skills(預設:~/.codex/skills),包含 .system/ 下的內建系統 skills。Codex 支援以符號連結連接的 skill 資料夾。
| 範圍 | 路徑 |
|---|---|
| 專案/團隊 | 儲存庫 skill 資料夾(配置可能因版本而異) |
| 使用者 | ~/.codex/skills/(或 $CODEX_HOME/skills/) |
| 管理員 | /etc/codex/skills/ |
| 系統 | 由 OpenAI 隨附(位於 ~/.codex/skills/.system/ 下) |
建立 Skill
SKILL.md 格式:
---
name: security-audit
description: Run a thorough security audit on the codebase.
---
## Security Audit Procedure
1. Scan for hardcoded secrets using `rg -i "(api_key|password|secret|token)\s*=" --type py`
2. Check for SQL injection: look for string interpolation in queries
3. Verify input validation on all API endpoints
4. Check dependency vulnerabilities: `pip audit` or `npm audit`
5. Review authentication and authorization patterns
6. Report findings with severity levels (Critical/High/Medium/Low)
中繼資料(agents/openai.yaml):
interface:
display_name: "Security Audit"
short_description: "Full codebase security review"
icon_small: "./assets/shield.svg"
brand_color: "#DC2626"
default_prompt: "Run a security audit on this repository"
policy:
allow_implicit_invocation: false # Require explicit $skill
dependencies:
tools:
- type: "mcp"
value: "snyk"
transport: "streamable_http"
url: "https://mcp.snyk.io/mcp"
呼叫 Skills
- 明確呼叫:在
/skills選單中選取,或在 prompt 中提及$skill-name - 隱含呼叫:Codex 會依任務描述自動偵測相符的 skills(若
allow_implicit_invocation: true) - 建立工具:使用
$skill-creator以互動方式建立新的 skill - 安裝工具:使用
$skill-installer install <name>安裝社群 skills
啟用/停用
[[skills.config]]
path = "/path/to/skill/SKILL.md"
enabled = false
Skills 與 Slash Commands
| Skills | Slash Commands | |
|---|---|---|
| 定義於 | SKILL.md 檔案,可搭配選用中繼資料 |
內建於 Codex CLI binary |
| 範圍 | 專案、使用者或管理員層級 | 全域(永遠可用) |
| 呼叫方式 | prompt 中的 $skill-name、/skills 選單,或隱含偵測 |
/command 語法 |
| 可自訂性 | 完全可自訂,指令由您撰寫 | 行為固定 |
| 依賴項 | 可宣告 MCP server 需求 | 無 |
| 分享方式 | 將 skill 資料夾複製到團隊 repo 或 ~/.codex/skills/ |
無法分享 |
偵錯 Skills
如果某個 skill 未啟用:
- 檢查探索結果:
/skills應會在 TUI 中列出該 skill - 驗證路徑:確認 skill 資料夾位於可辨識的位置(
~/.codex/skills/、專案根目錄或/etc/codex/skills/) - 檢查
enabled:config.toml 中設定為enabled = false的 skills 不會載入 - 檢查隱含啟用:若仰賴自動偵測,請確認
agents/openai.yaml中有allow_implicit_invocation: true - 使用關鍵字:在 prompt 中包含該 skill 的
description用詞,以提升隱含比對的準確度
Production 範例:Deploy Skill
完整的多檔案 skill,展示 references 與 scripts 如何協同運作:
deploy-skill/
SKILL.md
references/
runbook.md
rollback-checklist.md
scripts/
pre-deploy-check.sh
smoke-test.sh
agents/openai.yaml
SKILL.md:
---
name: deploy
description: Deploy the application to staging or production. Runs pre-flight checks, executes deployment, and verifies with smoke tests.
---
## Deployment Procedure
### Pre-flight
1. Run `scripts/pre-deploy-check.sh` to verify:
- All tests pass
- No uncommitted changes
- Branch is up to date with remote
2. Review the runbook at `references/runbook.md` for environment-specific steps.
### Deploy
3. Execute the deployment command for the target environment.
4. Monitor logs for errors during rollout.
### Verify
5. Run `scripts/smoke-test.sh <environment-url>` to confirm critical paths.
6. If smoke tests fail, follow `references/rollback-checklist.md`.
呼叫方式:$deploy to staging 或 $deploy production with canary rollout
Plugins
Plugins將skills、MCP項目、hooks與app connectors整合為單一可安裝套件(v0.110.0+)。65自v0.117.0起,plugins成為一級功能:產品範圍的plugins會在啟動時自動同步,/plugins也提供TUI內建瀏覽器,方便探索與管理。75v0.128.0擴充了plugin工作流程,加入marketplace安裝、遠端bundle快取、遠端解除安裝API、plugin內建hooks、hook啟用狀態,以及外部agent設定匯入。86v0.129.0(2026年5月7日)新增plugin workspace sharing(無須重新發布即可將plugin組合推送給隊友)、share access controls(依收件者啟用/停用、撤銷)、source filtering(限制workspace從哪些marketplaces拉取),以及可直接從/plugins瀏覽器呼叫的marketplace operations,不必透過CLI。89v0.133.0(2026年5月21日)讓plugin探索更易於稽核:清單輸出會感知marketplace、可看見已安裝版本、會列出marketplace roots,也能顯示遠端plugin collections,無須猜測結果來自哪個registry。98v0.130.0(2026年5月8日)讓plugin封裝更透明,也讓分享工作流程更可控:91
- Plugin詳細資料會顯示內建hooks。
/plugins詳細檢視現在會列出plugin內建的每個生命週期hook(SessionStart、UserPromptSubmit、Stop等)。安裝plugin之前,您可以清楚看見它會在您的session中註冊哪些hooks,不會再因為只信任plugin工具而意外承受hook副作用。 shareContext中的plugin分享metadata。從workspace分享plugin時,share-link payload現在會公開連結metadata(建立者、範圍、新鮮度),讓接收端session能顯示來源並判斷是否接受。- 分享設定中的可探索性控制。分享設定提供discoverability切換,團隊可將plugins發布到特定workspaces或收件者清單,而不必讓它們在整個組織中普遍可列出。
Plugin來源
| Source | Location | Description |
|---|---|---|
| Config | config.toml |
手動宣告的plugins |
| 本機marketplace | marketplace.json |
專案本機plugin catalog |
| 安裝endpoint | App server v2 | 遠端plugin安裝 |
| 產品範圍 | 啟動時同步 | 自動同步的plugins(v0.117.0+) |
Plugin探索
Codex會在session開始時告知model哪些plugins已啟用(v0.111.0),改善已安裝MCP、apps與skills的探索能力。65model可根據任務情境,在session期間建議相關plugins。在v0.117.0中,產品範圍的plugins會在啟動時同步,確保最新plugin catalog可用,無須手動介入。75截至v0.142.0,/plugins選單會將遠端plugins整理為OpenAI Curated、Workspace與Shared with me區段,符合條件的turn也能在行內推薦並安裝相關plugins。104
@plugin提及(v0.112.0+)
直接在chat中用@plugin-name參照任何已安裝plugin。68提及plugin時,其context(功能、工具、設定)會自動納入model的context window,不必另外描述該plugin的用途。
@deploy push this branch to staging with canary rollout
@linter check for unused imports in src/
這適用於任何已安裝plugin,包括自訂skills、MCP伺服器與app connectors。
Plugin Marketplace(v0.113.0+)
plugin marketplace現在透過metadata、分類與評分提供更豐富的探索體驗。69安裝時的auth檢查會確認需要API keys或OAuth的plugins在安裝前具備有效憑證。解除安裝endpoint會乾淨移除plugins及其相關設定。
新增第三方Marketplaces(v0.121.0+)
目前OpenAI Codex文件將marketplace來源管理放在codex plugin marketplace之下。這讓OpenAI第一方marketplace以外的第三方plugin發布正式化,並支援GitHub repo縮寫、HTTP(S) Git URLs、SSH URLs與本機marketplace root directories;使用--ref固定Git ref,且只有Git-backed marketplace repos才重複使用--sparse PATH。93
# GitHub repository (shorthand)
codex plugin marketplace add owner/repo
# Arbitrary git URL
codex plugin marketplace add https://git.example.com/team/plugins.git
# SSH Git URL
codex plugin marketplace add [email protected]:team/plugins.git
# Local directory
codex plugin marketplace add /path/to/local/marketplace
# Upgrade or remove a configured marketplace
codex plugin marketplace upgrade <marketplace-name>
codex plugin marketplace remove <marketplace-name>
新增後,該marketplace的plugins會與預設plugins一起出現在/plugins瀏覽器中。App-server呼叫端(IDE/desktop integrations)也有對應endpoint,可用程式化方式註冊marketplaces。82
安全性考量:第三方marketplaces會以您的Codex權限執行任意plugin程式碼。新增前務必審查來源,首次執行時建議優先使用沙盒化執行。
管理Plugins
codex plugin marketplace add <src> # Add a marketplace source
codex plugin marketplace upgrade [name] # Upgrade one marketplace or all
codex plugin marketplace remove <name> # Remove a configured marketplace
在TUI中,使用/plugins(v0.117.0+)即可互動式瀏覽、安裝與移除個別plugins,無須離開目前session。75
專家提示:Plugins整合了過去需要分別設定MCP、安裝skill與設定app connector的工作。單一plugin可以打包這三者,讓團隊onboarding更快,設定也更便於攜帶。
Plan Mode與協作
Plan mode讓Codex在執行變更前先設計做法。此功能預設啟用(自v0.94.0起)。14請參閱決策框架,查看「Plan Mode vs Direct Execution」決策樹。
進入Plan Mode
/plan # Switch to plan mode
/plan "redesign the API layer" # Plan mode with initial prompt
在plan mode中,Codex會: - 讀取檔案並分析codebase - 提出實作計畫 - 在您核准前不會進行變更 - 在專用TUI檢視中串流顯示計畫
Steer Mode
Steer mode(自v0.98.0起預設啟用)讓您能在Codex主動工作時注入新指示,而不中斷目前任務。14
有兩種注入方式:
| Input | Behavior | When to Use |
|---|---|---|
| Enter | 立即送出指示;Codex會在目前turn中看到 | 緊急修正(「stop — don’t modify that file」)、釐清(「設定在/etc/app.conf,不是預設路徑」),或優先順序變更(「先專注在tests」) |
| Tab | 將指示排入下一個turn;Codex會先完成目前工作 | 後續任務(「完成後也更新changelog」)、範圍追加(「做完後執行linter」),或非緊急情境(「deploy目標是staging,不是prod」) |
實務範例:
# Codex is refactoring the auth module...
[Enter] "Use bcrypt instead of argon2 — we already have it as a dependency"
→ Codex adjusts immediately, mid-turn
[Tab] "Once auth is done, update the migration script too"
→ Codex finishes auth refactor, then starts the migration
Steer mode在TUI中永遠啟用。若偏好等Codex完成後再給指示,只要在該turn完成後正常輸入即可,不需要特別切換模式。
TUI增強功能(v0.105.0–v0.106.0)
Syntax highlighting(v0.105.0):TUI現在會在行內對fenced code blocks與diffs進行syntax highlighting。使用/theme選擇配色方案。61
新的TUI commands(v0.105.0+):61
| Command / Key | Description |
|---|---|
/copy |
將上一則回應複製到剪貼簿 |
/clear |
清除TUI畫面 |
Ctrl+L |
清除畫面(鍵盤快速鍵) |
/theme |
切換syntax highlighting配色方案 |
/plugins |
瀏覽、安裝與移除plugins(v0.117.0+)75 |
/title |
設定terminal window標題;適用於TUI與app-server TUI(v0.117.0+)75 |
/archive |
封存目前session;封存後的sessions在還原前會受到保護,無法resume/fork(v0.136.0+)108 |
語音轉錄(v0.105.0,實驗性):按下空白鍵即可透過語音轉錄口述prompts。此功能仍屬實驗性,可能需要麥克風權限。61截至v0.107.0,realtime voice sessions支援選擇麥克風與喇叭裝置,讓您指定音訊輸入/輸出硬體。62已於v0.140.0移除:實驗性的/realtime語音控制及其音訊相依項已從TUI移除;空白鍵語音轉錄不受影響。102
其他改進:
- 長連結即使跨TUI行換行,現在仍可點擊(v0.105.0)61
- 本機檔案連結以改良後的格式呈現(v0.106.0)60
- TUI markdown透過OSC 8 metadata讓網頁連結保持可點擊;過於擁擠的tables會退回可讀的key/value records,同時保留link targets(v0.136.0)108
- 修正sub-agents的Ctrl+C處理,可正確終止child processes(v0.106.0)60
記憶系統
Codex具備持久化記憶系統(v0.100.0+),可跨 session 儲存事實、偏好與專案脈絡。24
記憶指令
| 指令 | 說明 |
|---|---|
/m_update <fact> |
儲存一則記憶(例如:/m_update always use pytest, never unittest) |
/m_drop <query> |
移除符合查詢的記憶 |
記憶會儲存在 ~/.codex/memory/ 下的 markdown 檔案中。Codex會在 session 開始時載入這些記憶,並用來引導所有後續 session 的行為。
適合儲存的內容
記憶最適合用於持久偏好與專案事實:
- 專案慣例:「此專案使用 tab,而不是空格」或「API 回應一律包含
meta欄位」 - 工具偏好:「使用
pnpm而不是npm」或「以pytest -x --tb=short執行測試」 - 架構決策:「auth 模組位於
src/core/auth/,不是src/middleware/」 - 工作流程偏好:「顯示 diff 給我之前,一律先執行 linter」
Pipeline 中的記憶
執行 codex exec 時,記憶會自動載入。這表示 CI/CD pipeline 與指令稿能享有與互動式 session 相同的脈絡,不必在每次呼叫時重複指示。
記憶改進(v0.101.0–v0.107.0)
- Secret 清理:記憶寫入磁碟前,會自動掃描是否包含 secret
- CWD 感知:記憶檔案現在會包含工作目錄脈絡,方便專案特定的回想
- 排除 developer message:developer/system message 會從 phase-1 記憶輸入中排除,讓記憶更聚焦於使用者互動,提升品質
- 以 diff 為基礎的遺忘(v0.106.0):記憶現在使用以 diff 為基礎的遺忘機制移除過時事實,讓記憶儲存長期保持精簡且相關60
- 使用量感知選取(v0.106.0):記憶擷取現在具備使用量感知,會優先選取經常存取且近期相關的記憶60
- 可設定記憶(v0.107.0):記憶現在已可完整設定。使用
codex debug clear-memories可重設所有已儲存記憶,讓狀態歸零。這在切換無關專案脈絡,或記憶狀態已偏移時特別有用62 - Phase-2 模型升級(v0.121.0):phase-2 記憶整合模型現在是
gpt-5.4(由先前預設值升級)。phase-2 pipeline 會在 session 之間執行,將 phase-1 transcript 萃取成持久事實;這項模型變更在相同 token 成本下提升回想品質。82 - TUI 記憶選單(v0.121.0):新的 session 內 UI 會顯示記憶模式、個別記憶刪除,以及重設按鈕。記憶重設現在會保留過去 rollout,而不是使其失效,因此重設會清除未來的回想介面,同時不破壞 session replay。82
記憶 vs AGENTS.md
| 使用情境 | 記憶(/m_update) |
AGENTS.md |
|---|---|---|
| 個人偏好 | 使用記憶(跨所有專案持續保存) | 不適合 |
| 專案慣例 | 兩者皆可(記憶用於個人回想,AGENTS.md 用於團隊共享) | 團隊使用 AGENTS.md |
| 架構決策 | AGENTS.md(共享脈絡) | 主要選擇 |
| 工具指令 | 記憶(快速個人參考) | 團隊使用 AGENTS.md |
提示:對於應無限期保留的事實,請使用
/m_update。若是 session 特定脈絡,直接在對話中告訴 Codex 即可。若是團隊共享脈絡,請使用 AGENTS.md。
Session 管理
Codex會將 session 持久保存在 ~/.codex/sessions/ 下,讓您能在 CLI 與桌面介面之間進行 resume、fork 與多執行緒工作流程。
Resume
從先前中斷處繼續:
codex resume # Interactive picker (sorted by recency)
codex resume <SESSION_ID> # Resume a specific session
codex exec resume --last "continue" # Non-interactive: resume most recent
TUI 內的 /resume slash command 會開啟相同的互動式選擇器,並支援搜尋。
Fork
分支一段對話以探索替代方案,同時保留目前進度:
/fork # Fork current conversation
/fork "try a different approach" # Fork with new prompt
Fork會建立獨立 thread,並共享直到 fork 點為止的相同歷史。一個 fork 中的變更不會影響另一個。這很適合用來比較做法(例如「fork and try Redis instead of Memcached」),或安全地探索高風險變更。
將 thread fork 到 sub-agent(v0.107.0):Thread現在可以 fork 成獨立 sub-agent,讓一段對話能產生平行工作流,並自主執行。這延伸了既有 fork 模型:不只是分支對話,fork 出來的 thread 會成為具備自身執行脈絡的 sub-agent。62截至 v0.117.0,sub-agent 使用以路徑為基礎的位址(例如 /root/agent_a),並具備結構化的 agent 間訊息傳遞,讓多 agent 協調更明確、也更容易除錯。75
Thread 清單
檢視並管理作用中的 session:
/status # Current session info and token usage
/ps # Show background terminals in session
在桌面 app 中,thread 會顯示於側邊欄,並包含完整歷史與 diff 預覽。
Session 生命週期
| 動作 | CLI | 桌面 App |
|---|---|---|
| 開始新的 | codex 或 /new |
New Thread 按鈕 |
| Resume | codex resume 或 /resume |
在側邊欄點選 thread |
| Fork | /fork |
右鍵點選 thread → Fork |
| 結束 | /quit 或 Ctrl+C |
關閉 thread 分頁 |
| 刪除 | 從 ~/.codex/sessions/ 移除 |
右鍵 → Delete |
Session會在 CLI 與桌面 app 之間同步:可在其中一處開始,並在另一處繼續。
非互動模式(codex exec)
codex exec會以非互動方式執行Codex,適用於指令碼、CI/CD與自動化。15
基本用法
codex exec "summarize the repository structure"
codex exec --sandbox workspace-write --ask-for-approval on-request "fix the CI failure"
codex exec --json "triage open bugs" -o result.txt
預設情況下,codex exec會將進度/事件寫入stderr,並將最終 agent 訊息寫入stdout。這項設計讓它能與標準Unix管線順暢組合。
工作階段封存(v0.136.0)
您可以封存工作階段,讓 resume/fork 清單保持聚焦,同時不刪除歷史記錄。可在TUI中使用/archive封存,或從shell執行:108
codex archive <session-id> # archive a session
codex unarchive <session-id> # restore it
封存後的工作階段在取消封存前,會受到保護,無法進行 resume 或 fork 操作。這是一道防護措施,避免您不小心繼續原本打算退役的工作階段。同一版本中,codex app-server --stdio會以stdio模式啟動app-server,供編輯器/主機整合使用;/diff現在也會阻止執行儲存庫提供的Git helper(這是一項命令安全性修正)。在Windows上,alpha 版佈建路徑新增了供系統管理員使用的codex sandbox setup --elevated。108
JSON Lines 輸出
搭配--json時,stdout會變成JSONL事件串流:
codex exec --json "fix the tests" | jq
事件類型:thread.started、turn.started/completed/failed、item.started/completed、error
{"type":"thread.started","thread_id":"019c5c94-..."}
{"type":"turn.started"}
{"type":"item.started","item":{"id":"item_1","type":"command_execution","status":"in_progress"}}
{"type":"item.completed","item":{"id":"item_3","type":"agent_message","text":"..."}}
{"type":"turn.completed","usage":{"input_tokens":24763,"cached_input_tokens":24448,"output_tokens":122}}
結構化輸出
使用JSON Schema強制規範回應形狀:
codex exec "Extract project metadata" \
--output-schema ./schema.json \
-o ./project-metadata.json
-o / --output-last-message會將最終訊息寫入檔案。
工作階段續接與檢閱
codex exec resume --last "continue where you left off"
codex exec resume <SESSION_ID> "fix the remaining issues"
codex exec review --base main # Code review against a branch
主要旗標
| Flag | 說明 |
|---|---|
--sandbox workspace-write --ask-for-approval on-request |
工作區範圍內的自動化,越界時需取得核准 |
--json |
將JSONL事件串流輸出到stdout |
-o, --output-last-message <file> |
將最終訊息儲存到檔案 |
--output-schema <file> |
依照JSON Schema驗證回應 |
--ephemeral |
不持久保存工作階段檔案 |
-C, --cd <dir> |
設定工作目錄 |
--add-dir <dir> |
額外可寫入的目錄 |
--skip-git-repo-check |
允許在git repo外執行 |
--dangerously-bypass-approvals-and-sandbox |
無sandbox、無核准(僅限CI) |
CI驗證
codex exec支援在自動化環境中使用CODEX_API_KEY進行非互動驗證。
codex exec啟動橫幅(v0.130.0)。codex exec啟動橫幅不再列印舊版「research preview」字樣。如果您的CI會擷取啟動輸出,現在橫幅文字更精簡;結構化--json事件維持不變。91
codex remote-control(v0.130.0+)
codex remote-control是一個頂層命令,會啟動 headless app-server,設計上可由另一個程序驅動,例如IDE擴充功能、自訂協調器或遠端控制平面。它取代了許多整合者手動拼接的多旗標codex app-server呼叫,並為第三方工具提供單一且穩定的進入點,連到桌面與IDE介面底下相同的app-server執行環境。91 v0.133.0改善了此命令的執行形態:它可以像前景命令一樣執行、等待就緒、回報機器狀態,同時仍提供明確的 daemon 風格start / stop命令,供長時間運作的控制器設定使用。98
# Start a headless, remotely controllable app-server
codex remote-control
# Same lifecycle as a TUI session: thread store, hooks, plugins, MCP, sandbox
# all initialize from your normal config.toml.
如果您正在建置需要列舉大量 thread 歷史、但不想一次把每個 turn 都載入記憶體的UI,請將codex remote-control與下方app-server分頁API搭配使用。
App-Server Thread 分頁(v0.130.0+)
App-server用戶端現在可以透過3種不同的 turn item view,對大型thread進行分頁:91
| View | 使用情境 |
|---|---|
| Unloaded | 僅供列出清單使用,提供不含 turn payload 的 thread 結構(成本最低) |
| Summary | 精簡的每個 turn 中繼資料,適合側邊欄與 resume picker |
| Full | 完整 turn payload,包含工具呼叫與輸出 |
請將分頁功能與v0.121.0引入的ThreadStore介面搭配使用,以便有效率地走訪長時間執行的thread。這在remote-control部署中特別有用,因為協調器可能位於不同於 rollout 檔案的另一台機器上。82
即時 App-Server 設定重新整理(v0.130.0+)
即時app-server thread現在會在不需要重新啟動的情況下套用config.toml變更。編輯設定、儲存後,正在執行的thread會在下一個turn反映新值。這是codex remote-control的對應錯誤修正:長時間運作的headless server可以原地重新設定,而不必拆除重建。91
加密遠端執行器(v0.141.0)
自v0.141.0(stable,2026年6月18日)起,遠端執行器會透過已驗證、端對端加密的Noise-relay通道連線。控制平面與執行器不再需要信任夾在中間的relay;當您的協調器跨網路邊界驅動app-server時,這點格外重要。同一版本也讓跨平台遠端執行保留執行器原生的工作目錄與shell,因此某個作業系統上的控制器驅動另一個作業系統上的執行器時,底層不會再改寫路徑或shell語意。TLS現在也接受P-521憑證簽章,以相容企業Proxy。103
Codex Cloud與背景任務[EXPERIMENTAL]
狀態:Codex Cloud是實驗性功能。介面、定價與可用性都可能變更。OpenAI負責管理雲端環境,您無法控制基礎架構。
Codex Cloud會在OpenAI管理的環境中非同步執行任務。4 若要將Codex整合到CI管線,也請參閱GitHub Action與CI/CD。
運作方式
- 提交任務(透過chatgpt.com/codex、Slack整合或CLI)
- Codex會將您的repo複製到隔離的雲端sandbox
- agent獨立作業:讀取程式碼、執行測試、進行變更
- 完成後,Codex會建立PR,或提供diff供檢閱
- 使用
codex apply <TASK_ID>在本機套用結果
Cloud中的網際網路存取
Agent網際網路預設為關閉,並且依環境設定:
- Off:agent無法存取網際網路(預設)
- On:可選擇設定網域 allowlist + HTTP方法限制
Allowed domains: pypi.org, npmjs.com, github.com
Allowed methods: GET, HEAD, OPTIONS
即使agent網際網路關閉,設定指令碼仍可使用網際網路安裝相依套件。
Slack整合
在Slack頻道或thread中提及@Codex即可啟動雲端任務。
先決條件: 1. 符合資格的ChatGPT方案(Plus、Pro、Business、Enterprise或Edu) 2. 已連線的GitHub帳戶 3. 至少1個已設定的雲端環境 4. 已為您的workspace安裝Slack app
Codex會回覆任務連結,並在完成後發布結果。
Cloud CLI
codex cloud exec --env <ENV_ID> "Fix failing tests" # Start a cloud task
codex cloud status <TASK_ID> # Check task progress
codex cloud diff <TASK_ID> # View task diff
codex cloud list # List recent tasks
codex cloud list --json # JSON output
codex cloud apply <TASK_ID> # Apply from cloud subcommand
codex apply <TASK_ID> # Apply diff (top-level shortcut)
Codex Desktop App
Codex desktop app(macOS與Windows)提供針對多專案管理最佳化的圖形介面。16 Windows版本已於2026年3月4日推出,支援原生PowerShell與原生Windows sandbox。66
安裝
codex app # Auto-downloads and installs on first run
或直接下載:Codex.dmg(macOS)| 可於Microsoft Store取得(Windows)
主要功能
| 功能 | 說明 |
|---|---|
| 平行threads | 同時跨專案執行多項任務 |
| Thread模式 | 以Local、Worktree或Cloud模式啟動threads |
| 內建Git工具 | 檢視diffs、新增comments、stage/revert chunks、commit/push、建立PRs |
| 整合式terminal | 每個thread各自的terminal(Cmd+J) |
| 語音聽寫 | 透過語音輸入prompt(Ctrl+M) |
| Automations | 排程週期性任務 |
| Notifications | app在背景執行時提供完成/核准notifications |
| 防止睡眠 | 可選設定,讓任務執行期間機器保持喚醒 |
| skills + MCP | app、CLI與IDE extension之間共用設定 |
| MCP shortcuts | composer中的快速存取MCP工具shortcuts(App v26.226)63 |
| Review @mentions | 在code review comments中@mention協作者(App v26.226)63 |
| 自訂themes | Settings中的色彩控制與字型選擇(App v26.312)72 |
| App-server TUI | 預設啟用(v0.117.0+):! shell commands、filesystem watch、使用bearer auth的remote WebSocket、跨sessions喚回prompt history75 |
| Appshots | macOS appshots會將最前方app視窗附加到thread,包含screenshot與可用文字,並可透過Appshots hotkey新增。99 |
| In-app browser comments | in-app browser可預覽local/public pages,並接受element或area comments,以提供精準的rendered-page feedback。99 |
| Computer Use + locked use | Computer Use讓Codex可操作允許的Mac apps,以處理有範圍的GUI任務;locked use採opt-in,且限於Mac鎖定後仍在進行中的受信任Computer Use turns。99 |
Appshots、Browser Comments與Computer Use
5月21日的app更新,讓desktop app不只是thread manager,而成為更強大的context surface。當Codex需要先取得另一個Mac app的狀態才能行動時,請使用Appshots:Codex會擷取最前方視窗、app公開的可見/畫面外文字,並將附件本機儲存在session history中。99
進行web與frontend工作時,若頁面不需要驗證,請先使用in-app browser:它為Codex與您提供共用的rendered preview,支援browser-use actions,例如點擊、screenshots、asset downloads與read-only inspection JavaScript,也能讓您用comments標記頁面區域,供Codex在下一輪處理。99 對於已登入的網站,請繼續使用Chrome extension。
只有在structured integration或browser preview無法驗證任務時,才使用Computer Use。它可以檢查並操作允許的Mac apps,但檔案編輯與shell commands仍繼承Codex approvals與sandbox規則。locked use也維持窄範圍:Mac鎖定後,Codex只能在進行中的受信任Computer Use turns期間暫時存取允許的apps,並具備重新鎖定保護與local-input detection。99
Thread模式
每個thread會在建立時選定的3種模式之一中執行:
| 模式 | 隔離 | 檔案存取 | 最適合 |
|---|---|---|---|
| Local | 無——直接在您的專案目錄中運作 | 完整read/write | 快速任務、探索、非破壞性工作 |
| Worktree | Git worktree——repo的隔離branch副本 | 隔離副本 | 功能開發、高風險refactors、平行實驗 |
| Cloud | 遠端伺服器——在OpenAI基礎架構上執行 | 無本機存取 | 長時間執行的任務、類CI workflows、非同步委派 |
Worktree隔離機制:
啟動Worktree thread時,desktop app會:
1. 在暫存目錄中建立新的git worktree(git worktree add)
2. 從目前HEAD checkout新的branch
3. 在worktree內執行agent——所有檔案變更都會被隔離
4. 完成後呈現diff review——由您選擇哪些變更要merge回來
這表示多個Worktree threads可以在同一個repo上同時執行且不會衝突。每個thread都有自己的branch與working directory。
Automations
Automations會在app本機執行,因此app必須保持執行,且專案必須可從磁碟存取:
- 在Git repos中,automations會使用專用的背景worktrees(與您的working directory隔離)
- 在非Git專案中,runs會直接在專案目錄中執行
- Automations會使用您的預設sandbox設定
設定automation: 1. 在desktop app中開啟專案 2. 點選sidebar中的Automations tab 3. 定義trigger(schedule、webhook或manual) 4. 撰寫prompt並選擇execution mode(local或worktree) 5. 設定automation run的reasoning level(App v26.312)72 6. Automations會依排程執行,並將結果排入review佇列
使用案例範例: - Issue triage:自動分類新issues並排定優先順序 - CI monitoring:監看build failures並建議修正方式 - Alert response:以診斷分析回應monitoring alerts - Dependency updates:檢查並套用security patches
結果會出現在review queue中,供人工核准。
Windows支援
Codex Desktop App已於2026年3月4日(App v26.304)在Windows推出,支援原生PowerShell、原生Windows sandbox,並完整支援skills、automations與worktrees等功能,無需WSL。66
GitHub Action與CI/CD
官方GitHub Action會將Codex整合到您的CI/CD pipeline。18
基本用法
# .github/workflows/codex.yml
name: Codex
on:
pull_request:
types: [opened]
jobs:
codex:
runs-on: ubuntu-latest
outputs:
final_message: ${{ steps.run_codex.outputs.final-message }}
steps:
- uses: actions/checkout@v5
- name: Run Codex
id: run_codex
uses: openai/codex-action@v1
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
prompt-file: .github/codex/prompts/review.md
sandbox: workspace-write
safety-strategy: drop-sudo
設定選項
| Input | 用途 |
|---|---|
openai-api-key |
用於proxy/auth設定的API key |
responses-api-endpoint |
覆寫endpoint(例如Azure Responses URL) |
prompt / prompt-file |
任務指示(必填其一) |
working-directory |
傳遞給codex exec --cd的目錄 |
sandbox |
workspace-write / read-only / danger-full-access |
codex-args |
額外CLI flags(JSON array或shell string) |
output-schema / output-schema-file |
用於--output-schema的structured output schema |
model / effort |
Agent設定 |
output-file |
將final message儲存到磁碟 |
codex-version |
固定CLI version |
codex-home |
自訂Codex home directory |
allow-users / allow-bots |
Trigger allowlist controls |
safety-strategy / codex-user |
Privilege-reduction behavior與user selection |
Output:final-message,供downstream steps/jobs使用的最終Codex response text。
Safety Strategies
| Strategy | 說明 |
|---|---|
drop-sudo(預設) |
Linux/macOS;在action step後移除sudo能力 |
unprivileged-user |
以預先建立的低權限user執行Codex |
read-only |
Read-only sandbox(runner/user privilege風險仍然存在) |
unsafe |
不進行privilege reduction;Windows runners需要此選項 |
存取控制
with:
allow-users: "admin,maintainer" # Limit who can trigger
allow-bots: false # Block bot-triggered runs
預設:只有具備write access的collaborators可以觸發Codex workflows。
Codex SDK
TypeScript SDK會將 Codex 的代理能力嵌入自訂應用程式。19
安裝
npm install @openai/codex-sdk
基本用法
import { Codex } from "@openai/codex-sdk";
const codex = new Codex();
const thread = codex.startThread();
// Multi-turn conversation
const turn1 = await thread.run("Diagnose CI failures and propose a fix");
console.log(turn1.finalResponse);
const turn2 = await thread.run("Implement the fix and add tests");
console.log(turn2.items);
// Resume a previous session
const resumed = codex.resumeThread("<thread-id>");
await resumed.run("Continue from previous work");
進階SDK功能
runStreamed(...):用於中繼更新的非同步事件串流- Python SDK auth(v0.132.0+):API-key登入、ChatGPT瀏覽器/裝置碼流程、帳號檢查與登出,都是第一級SDK路徑。97
- 純文字回合便利功能(v0.132.0+):Python turn APIs接受純字串,並回傳更豐富的
TurnResult中繼資料,包含收集項目、時間與用量。97 outputSchema:強制最終輸出符合JSON形狀- 多模態輸入:傳入文字+本機圖片(
{ type: "local_image", path: "..." }) - 圖片工作流程(v0.117.0):
view_image會回傳URL,產生的圖片可重新開啟,圖片歷史也會在session resume後保留75 - 多環境
view_image(v0.130.0):針對跨多個環境的session(v0.124.0引入每回合環境+工作目錄選擇,v0.125.0再以黏著環境精進),view_image現在會透過所選環境解析檔案路徑,而不是透過orchestrator的本機檔案系統。從遠端環境附加的圖片,會相對於該環境的工作目錄擷取,而不是相對於執行SDK的主機。91
Thread與Client設定
// Custom working directory, skip git check
const thread = codex.startThread({
workingDirectory: "/path/to/project",
skipGitRepoCheck: true,
});
// Custom environment and config overrides
const codex = new Codex({
env: { CODEX_API_KEY: process.env.MY_KEY },
config: { model: "gpt-5.5" },
});
Sessions會保存在~/.codex/sessions底下。
Runtime:Node.js 18+。
效能最佳化
Context管理
Context window會依模型而異。截至2026年4月:Codex中的GPT-5.5提供400K(在API中為1M)。GPT-5.4/GPT-5.4-mini分別提供1M/400K(在Codex中相當於API)。GPT-5.3-Codex/GPT-5.2-Codex系列使用272K輸入+128K輸出(總預算400K)。它們都會比預期更快填滿,請主動管理:
- 定期使用
/compact:摘要對話歷史以釋放tokens - 提供本機文件:高品質的
AGENTS.md與本機文件可降低探索開銷(探索會消耗context) - 使用
@附加特定檔案:直接參照檔案,而不是要求Codex尋找 - 保持prompt聚焦:指定確切檔案的範圍化prompt,比開放式探索消耗更少context
Token效率
| 技巧 | 影響 |
|---|---|
設定model_reasoning_summary = "none" |
減少約20%輸出tokens |
使用model_verbosity = "low" |
說明更短,行動更多 |
| 針對簡單任務使用mini模型 | 每則訊息成本明顯更低 |
| 將複雜任務拆成聚焦session | 每個session的token效率更好 |
| 使用profiles依任務切換設定 | 避免例行工作也支付高reasoning成本 |
速度最佳化
gpt-5.3-codex-spark:互動配對用的較低延遲變體--profile fast:預先設定的mini模型,搭配低reasoning- 平行工具執行:Codex會並行執行彼此獨立的讀取/檢查,因此請安排prompt結構以利平行化
- 結果導向迴圈:要求「實作、測試、修正,綠燈後停止」,而不是逐步指示
如何偵錯問題?
常見問題與解法
| 問題 | 原因 | 解法 |
|---|---|---|
| 「Re-connecting」迴圈 | 多個Codex執行個體 | 結束所有程序,等待60秒,重新啟動單一執行個體 |
| 401 auth錯誤 | 憑證過期 | rm ~/.codex/auth.json && codex login |
| Sandbox中網路遭封鎖 | 預設行為 | -c 'sandbox_workspace_write.network_access=true' |
| WSL2斷線 | WSL狀態損毀 | 在PowerShell中執行wsl --shutdown,等待1分鐘後重新啟動 |
| Patch失敗 | 換行字元不一致 | 正規化為LF,提供精確的檔案文字 |
| Context compacting失敗 | context過多 | 降低reasoning effort,拆成更小任務 |
| 模型意外變更 | Config.toml覆寫 | 執行/config檢查有效設定與來源 |
| Plan mode允許變更 | 已知bug | Issue #11115 |
| 忘記AGENTS.md指示 | Context限制 | 保持指示精簡;詳細程序使用skill檔案 |
| 在Read Only模式停滯 | 已知問題 | Discussion #7380 |
錯誤訊息參考
| 錯誤訊息 | 意義 | 修正 |
|---|---|---|
Error: EACCES permission denied |
Sandbox封鎖了檔案操作 | 檢查sandbox mode;若Codex需要編輯檔案,使用workspace-write |
Error: rate limit exceeded |
觸及API rate limit | 等待後重試;降低model_reasoning_effort或切換到較輕量模型 |
Error: context length exceeded |
對話超過272K輸入tokens | 使用/compact摘要,或用/new開始新的session |
Error: MCP server failed to start |
MCP server程序當機或逾時 | 檢查codex mcp get <name>的設定;提高startup_timeout_sec |
Error: authentication required |
沒有有效的API key或session | 執行codex login或設定CODEX_API_KEY |
Error: sandbox execution failed |
指令在sandbox內失敗 | 檢查指令語法;確認sandbox環境中有可用的必要工具 |
WARN: skill not found |
參照的skill不存在於預期路徑 | 檢查/skills清單;確認skill資料夾位置 |
Error: wire format mismatch |
provider的wire_api設定錯誤 |
對OpenAI endpoints使用wire_api = "responses"(請參閱Custom Model Providers) |
診斷工具
codex --version # Check CLI version
codex login status # Verify authentication
codex mcp list # Check MCP server status
codex debug app-server --help # Debug app server issues
Session內TUI診斷:
/status # Token/session overview
/config # Inspect effective config values and sources
/compact # Summarize history to reclaim context
注意:
codex --verbose不是有效的頂層flag。請使用上方的debug子命令與TUI診斷。
乾淨重新安裝
npm uninstall -g @openai/codex && npm install -g @openai/codex@latest
Debug模式
codex debug app-server send-message-v2 # Test app-server client
回報問題
/feedback # Send logs to Codex maintainers (in TUI)
或到github.com/openai/codex/issues提交issue。1
Codex Security [PREVIEW]
Codex Security於2026年3月6日進入research preview,將具備context感知能力的應用程式安全審查帶入Codex堆疊。77 ChatGPT Pro、Enterprise、Business與Edu客戶可透過Codex web使用。
運作方式:Codex Security會分析repository,建立專案專屬的威脅模型,找出依真實世界影響分類的漏洞,並在sandboxed環境中對發現項目進行壓力測試以驗證。代理會提出信心較高的發現與修正,降低不重要bug造成的雜訊。
效能:在research preview期間,Codex Security掃描了120萬個commits,並識別出10,561個高嚴重性漏洞。精準度隨時間提升:雜訊減少84%,過度回報嚴重性的情況減少90%以上,false positive比率減半。此系統已在OpenSSH、GnuTLS與Chromium中找到真實漏洞,並已指派14個CVE。77
注意:Codex Security不同於CLI內建的sandbox安全模型。Sandbox會保護您的機器不受Codex影響;Codex Security則保護您的codebase免於漏洞。
企業部署
管理員控制(requirements.toml)
管理員可透過 requirements.toml 強制執行企業政策。這是一個由管理員強制套用的設定檔,用來限制使用者無法覆寫的安全敏感設定:21
# /etc/codex/requirements.toml
# Restrict which approval policies users can select
allowed_approval_policies = ["untrusted", "on-request", "never"]
# Limit available sandbox modes
allowed_sandbox_modes = ["read-only", "workspace-write"]
# Control web search capabilities
allowed_web_search_modes = ["cached"]
# Allowlist MCP servers by identity (both name and identity must match)
[mcp_servers.approved-server]
identity = { command = "npx approved-mcp-server" }
# Admin-enforced command restrictions
[[rules.prefix_rules]]
pattern = [{ token = "rm" }, { any_of = ["-rf", "-fr"] }]
decision = "forbidden"
justification = "Recursive force-delete is prohibited by IT policy"
[[rules.prefix_rules]]
pattern = [{ token = "sudo" }]
decision = "prompt"
justification = "Elevated commands require explicit approval"
不同於用來設定偏好的使用者層級
config.toml,requirements.toml是一層硬性限制,用來約束使用者可選擇的值,而且使用者無法覆寫。管理員 requirements 規則只能 prompt 或 forbid(絕不會靜默允許)。
macOS MDM 設定
使用 com.openai.codex 偏好設定網域透過 MDM 發佈。21 Codex 支援標準 macOS MDM payload(Jamf Pro、Fleet、Kandji 等)。請將 TOML 編碼為 base64,且不要換行:
| Key | 用途 |
|---|---|
config_toml_base64 |
Base64 編碼的受管理預設值(使用者可變更的起始值) |
requirements_toml_base64 |
Base64 編碼、由管理員強制套用的 requirements(使用者無法覆寫) |
優先順序(由高到低):
- macOS 受管理偏好設定(MDM)
- 從雲端擷取的 requirements(ChatGPT Business / Enterprise)
/etc/codex/requirements.toml(本機檔案系統)
雲端 requirements 只會填入尚未設定的 requirement 欄位,因此較高優先順序的受管理層一律勝出。雲端 requirements 採盡力而為;如果擷取失敗或逾時,Codex 會在沒有雲端層的情況下繼續執行。
OpenTelemetry 整合
Codex 支援從標準 OTel 環境變數將 OpenTelemetry trace-context 傳遞至 OpenAI API 呼叫。啟動 Codex 前,請先設定標準環境變數:
# Point Codex at your OTel collector
export OTEL_EXPORTER_OTLP_ENDPOINT="https://otel-collector.internal:4318"
export OTEL_SERVICE_NAME="codex-cli"
export OTEL_RESOURCE_ATTRIBUTES="team=platform,env=production"
# Launch Codex — trace context propagates to all OpenAI API calls
codex
- 支援標準
OTEL_*環境變數(endpoint、service name、resource attributes) - Trace context 會透過 Codex 傳遞到 API 呼叫,支援端到端可觀測性
- 使用 resource attributes 依團隊、環境或專案標記 traces
- 啟用 prompt/tool logging 時,請留意隱私要求,因為 traces 可能包含程式碼片段
- 可設定的 OpenTelemetry trace metadata(v0.130.0+)。 除了標準
OTEL_RESOURCE_ATTRIBUTESenvelope 之外,codex-otelcrate 現在也公開可設定的 trace metadata,讓管理員能以組織專屬維度(成本中心、專案 ID、ticket 參照)標記 traces,而不必每次呼叫都從頭重建OTEL_RESOURCE_ATTRIBUTES。可搭配同一版本推出的更完整 review/feedback analytics,在 CLI、app-server 與 remote-control sessions 之間統一進行除錯與分流處理。91
企業存取
- ChatGPT Business / Enterprise / Edu:由組織管理員控管存取權,並自動套用從雲端擷取的 requirements。支援透過身分識別提供者(Okta、Entra ID 等)使用 SAML/OIDC 進行 SSO
- API:標準 API 驗證、計費與組織/專案控制。OpenAI 發佈 SOC 2 Type II 與 SOC 3 報告;Enterprise tier 可提供 HIPAA BAA
- Codex SDK:嵌入內部工具與工作流程
- 大規模政策強制執行:使用 MDM 發佈的
requirements_toml_base64或檔案系統層級的/etc/codex/requirements.toml
資料處理與合規: - 依 OpenAI 的 Business/Enterprise/API 條款,API 輸入/輸出不會用於訓練 - 關於資料落地,OpenAI API 流量預設會透過美國境內基礎架構路由;若有歐盟資料落地需求,請洽詢 OpenAI Enterprise 銷售團隊 - Session transcripts 會儲存在本機;只有 API 呼叫會離開機器 - ChatGPT Enterprise 支援 SOC 2、GDPR、CCPA 等合規框架
推出策略
建議組織採用分階段推出:
- 試行(第 1-2 週):部署給 3-5 位資深工程師,並使用
requirements.toml強制套用untrustedsandbox mode 與cachedweb search。蒐集 AGENTS.md 模式與 MCP server 需求的回饋。 - 團隊擴展(第 3-4 週):推廣至完整團隊。透過 MDM 或 repo 發佈團隊標準
config.toml。為可信任的 repositories 啟用workspace-writesandbox。 - CI 整合(第 5-6 週):將
codex-action加入 CI/CD pipelines,用於自動化 PR review 與測試產生。使用--ephemeral讓成本保持可預測。 - 全組織部署(第 2 個月以後):透過 MDM 部署,並使用
requirements.toml強制套用核准的 MCP servers、sandbox policies 與 model allowlists。
稽核模式
追蹤 Codex 使用情況並強制合規:
- OpenTelemetry traces:監控每個團隊的 API 呼叫量、token 使用量與延遲
- Session persistence:稽核
~/.codex/sessions/以供合規審查(在敏感情境中可用--ephemeral停用) - MCP identity enforcement:
requirements.toml會記錄遭封鎖的 server 嘗試,請審查是否有未授權工具使用 - Git 稽核軌跡:所有 Codex 檔案變更都會經過標準 git,請透過 branch history 與 PR diffs 審查
最佳實務與反模式
Prompting 模式
- 由限制驅動的 prompts:先說明邊界。「請勿變更 API contracts。只重構內部實作。」
- 結構化重現步驟:編號步驟比模糊描述更能產出有效的 bug 修正
- 驗證請求:結尾加上「執行 lint + 最小相關測試套件。回報 commands 和結果。」
- 檔案參照:使用
@filename將特定檔案附加到 context - 結果導向迴圈:「實作、執行測試、修正失敗,直到所有測試通過才停止。」Codex 會反覆迭代直到完成
測試哲學
社群逐漸收斂到以測試驅動的 AI 協作方式:22
- 事先定義測試作為完成訊號
- 讓 Codex 迭代直到測試通過(red → green → refactor)
- 採用 Tiger Style 程式設計模式
- 請求 patches 時提供精確的檔案文字。Codex 使用嚴格比對,而不是模糊的 AST-based patching
Context 管理最佳實務
- 提供高品質的本機文件,而不是依賴 web search
- 維護結構化 markdown,包含目錄與進度檔案(「漸進揭露」)
- 在 tracked files 中統一換行格式(LF vs CRLF),避免 patch 失敗
- 保持
AGENTS.md精簡,因為過長的 instructions 會被擠出 context
Git Workflow
- 在不熟悉的 repos 上執行 Codex 前,務必先建立新 branch
- 使用 patch-based workflows(
git diff/git apply),而不是直接編輯 - 像 code review PRs 一樣審查 Codex 建議
- 提交前使用
/diff驗證變更
社群 Skills 與 Prompts
feiskyer/codex-settings repository 提供社群維護的設定:23
可重用 prompts(位於 ~/.codex/prompts/):
- deep-reflector:從開發 sessions 中萃取學習成果
- github-issue-fixer [issue-number]:系統化 bug 分析與 PR 建立
- github-pr-reviewer [pr-number]:Code review workflows
- ui-engineer [requirements]:Production-grade frontend development
社群 skills:
- claude-skill:以 permission modes 將任務交接給 Claude Code
- autonomous-skill:具備進度追蹤的 multi-session task automation
- deep-research:Parallel sub-task orchestration
- kiro-skill:Requirements → design → tasks → execution pipeline
反模式
常見錯誤會浪費 tokens、產出不佳結果,或造成令人挫折的 workflows。
成本反模式
| 反模式 | 失敗原因 | 修正方式 |
|---|---|---|
對所有事情都使用 xhigh reasoning |
簡單任務上的 token 成本增加 3-5 倍,報酬遞減 | 預設使用 medium;僅將 xhigh 保留給 multi-file architecture decisions |
從不使用 /compact |
Context 填滿到 272K,responses 品質下降 | 每個重大里程碑後 compact,或當 /status 顯示使用量 >60% 時 compact |
| 在 CI 中執行 flagship model | 例行檢查成本高昂 | 建立 ci profile,使用 gpt-5.1-codex-mini 和 low reasoning |
Context 反模式
| 反模式 | 失敗原因 | 修正方式 |
|---|---|---|
| 開放式「explore everything」prompts | Codex 讀取數十個檔案,把 context 浪費在無關程式碼上 | 用特定檔案限定範圍:「Review src/auth/login.py and tests/test_auth.py」 |
專案中沒有 AGENTS.md |
Codex 浪費回合探索專案結構 | 加入 20 行的 AGENTS.md,包含關鍵 paths、conventions 和 test commands |
| 附加整個目錄 | 以無關檔案灌爆 context | 使用 @filename,只附加 Codex 需要的檔案 |
Workflow 反模式
| 反模式 | 失敗原因 | 修正方式 |
|---|---|---|
直接在 main 上工作 |
沒有安全網;高風險編輯難以還原 | 開始 Codex 前務必建立 feature branch |
提交前略過 /diff |
Codex 可能做出非預期變更 | 每次任務後、任何 commit 前都 review /diff |
| 忽略測試輸出 | 如果不標出失敗,Codex 可能在失敗狀態下繼續迭代 | 在 prompt 中使用「run tests and stop only when all pass」 |
| 從不 fork conversations | 一個錯誤轉向會污染整個 context | 在高風險探索前使用 /fork;丟棄不良 branches |
Prompt 反模式
| 反模式 | 失敗原因 | 修正方式 |
|---|---|---|
| 「Fix the bug」(沒有 context) | Codex 猜測是哪個 bug,並讀取所有內容 | 「Fix the TypeError in src/api/handler.py:42 — user.name is None when unauthenticated」 |
| 在一則訊息中放入多個任務 | Codex 會混淆任務並漏掉部分內容 | 每則訊息一個任務;使用 steer mode(Tab)排入 follow-ups |
| 每則訊息都重複 context | 在重複資訊上浪費 tokens | 使用 /m_update 保存持久 facts;參照先前 context |
Workflow Recipes
常見開發情境的端到端模式。
Recipe 1:新專案設定
mkdir my-app && cd my-app && git init
codex
> Create a FastAPI project with: main.py, requirements.txt, Dockerfile,
basic health endpoint, and a README. Use async throughout.
> /init
檢視產生的 AGENTS.md,編輯成符合您的 conventions,然後:
> Run the health endpoint test and confirm it passes
Recipe 2:每日開發流程
cd ~/project && git checkout -b feature/user-auth
codex
> @src/models/user.py @src/api/auth.py
Add password reset functionality. Requirements:
1. POST /api/auth/reset-request (email → sends token)
2. POST /api/auth/reset-confirm (token + new password)
3. Tests for both endpoints
Run tests when done.
使用 /diff review,然後 commit。
Recipe 3:使用 Plan Mode 進行複雜重構
codex
> /plan Migrate the database layer from raw SQL to SQLAlchemy ORM.
Constraints: don't change any API contracts, keep all existing tests passing.
檢視 plan。Approve 或 steer:
[Tab] Also add a migration script using Alembic
Codex 執行後,進行驗證:
> Run the full test suite and report results
> /diff
Recipe 4:使用 codex exec 進行 PR Review
codex exec --model gpt-5.1-codex-mini \
"Review the changes in this branch against main. \
Flag security issues, missed edge cases, and style violations. \
Format as a markdown checklist." \
-o review.md
Recipe 5:使用 Cloud Tasks 偵錯 [EXPERIMENTAL]
codex cloud exec --env my-env "Diagnose why the /api/orders endpoint returns 500 \
for orders with > 100 line items. Check the serializer, database query, \
and pagination logic. Propose a fix with tests."
稍後檢查進度:
codex cloud status <TASK_ID>
codex cloud diff <TASK_ID>
完成後在本機套用修正:
codex apply <TASK_ID>
遷移指南
從Claude Code遷移
| Claude Code概念 | Codex對應項目 |
|---|---|
CLAUDE.md |
AGENTS.md(開放標準) |
.claude/settings.json |
.codex/config.toml(TOML格式) |
--print旗標 |
codex exec子命令 |
--dangerously-skip-permissions |
--dangerously-bypass-approvals-and-sandbox |
| Hooks(12個以上事件) | Hooks(SessionStart、Stop、UserPromptSubmit、AfterAgent、AfterToolUse;v0.99.0–v0.116.0) |
| Subagents(Task工具) | Sub-agents(內部使用,最多6個;沒有面向使用者的Task工具對應項目) |
/compact |
/compact(相同) |
/cost |
/status(顯示token使用量) |
| Model:Opus/Sonnet/Haiku | Model:gpt-5.5 / gpt-5.4 / gpt-5.4-mini / 舊版gpt-5.3-codex變體(Codex使用OpenAI的GPT-5.x模型家族) |
claude --resume |
codex resume |
| 權限規則 | Sandbox modes + approval policies |
| settings.json中的MCP設定 | config.toml中的MCP設定 |
需要了解的主要差異:
- Sandbox位於OS層級:Codex使用Seatbelt/Landlock,而不是容器。限制在kernel層級運作,位於應用程式層之下。
- Hooks正在擴充:Codex現在支援5個hook事件:
SessionStart、Stop和UserPromptSubmit(v0.114.0–v0.116.0,實驗性),以及AfterAgent(v0.99.0)和AfterToolUse(v0.100.0)。此系統涵蓋工作階段生命週期、提示攔截,以及工具層級自動化。不過,Claude Code的12個以上生命週期事件仍提供更廣的涵蓋範圍。尚未涵蓋的自動化模式,請使用AGENTS.md指令或skills。 - Sub-agents v2(v0.117.0):Sub-agents現在使用路徑式位址(例如
/root/agent_a),並具備結構化的agent間訊息傳遞與agent列表功能。75這擴充了既有機制(最多6個並行,已從v0.91.0的12個下修)。多agent角色仍可透過config自訂(v0.104.0+)。47v0.105.0新增spawn_agents_on_csv,可跨資料列展開fanout,並提供進度追蹤與ETA。61Codex仍缺少Claude Code那種明確的Task工具UX,無法讓使用者直接指派委派任務;委派模式請使用cloud tasks或SDK編排。 - AGENTS.md可跨工具使用:您的AGENTS.md可在Cursor、Copilot、Amp、Jules、Gemini CLI,以及60,000多個open source專案中運作。CLAUDE.md僅限Claude。
- Profiles取代手動切換:不必每次執行都更改flags,請在config.toml中定義profiles。
從GitHub Copilot遷移
| Copilot概念 | Codex對應項目 |
|---|---|
| Copilot CLI(agentic terminal) | 互動式CLI或desktop app |
| 專門化agents(Explore、Plan) | Skills + plan mode + steer mode |
copilot-instructions.md / AGENTS.md |
AGENTS.md(相同標準) |
| MCP支援 | MCP支援(STDIO + HTTP) |
| ACP(Agent Client Protocol) | Hooks(AfterAgent、AfterToolUse) |
| Copilot SDK | Codex SDK(TypeScript) |
| Coding agent workflows | 具備sandbox/approval控制的Codex agent + cloud tasks |
您會獲得:
- OS層級sandboxing(Seatbelt/Landlock——由kernel強制執行,而非容器式)
- 使用codex apply進行cloud task委派
- 用於切換工作流程的config profiles
- 具備worktree隔離的desktop app
從Cursor遷移
| Cursor概念 | Codex對應項目 |
|---|---|
專案規則(.cursor/rules)/ AGENTS.md |
AGENTS.md + profiles/config |
| Agent chat/composer workflows | 互動式CLI或desktop app |
@檔案參照 |
@檔案參照(相同) |
| Apply/edit + review | 內建patching與diff review |
快速參考卡
╔═══════════════════════════════════════════════════════════════╗
║ CODEX CLI QUICK REFERENCE ║
╠═══════════════════════════════════════════════════════════════╣
║ ║
║ LAUNCH ║
║ codex Interactive TUI ║
║ codex "prompt" TUI with initial prompt ║
║ codex exec "prompt" Non-interactive mode ║
║ codex app Desktop app ║
║ codex resume Resume previous session ║
║ codex fork Fork a session ║
║ ║
║ FLAGS ║
║ -m, --model <model> Select model ║
║ -p, --profile <name> Load config profile ║
║ -s, --sandbox <mode> Sandbox mode ║
║ -C, --cd <dir> Working directory ║
║ -i, --image <file> Attach image(s) ║
║ -c, --config <key=value> Override config ║
║ --ask-for-approval <p> Approval policy ║
║ --oss Use local models (Ollama) ║
║ --search Enable live web search ║
║ ║
║ SLASH COMMANDS (in TUI) ║
║ /compact Free tokens /diff Git diff ║
║ /review Code review /plan Plan mode ║
║ /model Switch model /status Session info ║
║ /fork Fork thread /goal Persisted goal ║
║ /vim Modal Vim /hooks Browse/toggle hooks ║
║ /init AGENTS.md scaffold ║
║ /mcp MCP tools /skills Invoke skills ║
║ /ps Background /personality Style ║
║ /permissions Approval mode /statusline Footer config ║
║ /fast Toggle fast mode (default: on) ║
║ /copy Copy last response to clipboard ║
║ /clear Clear screen /theme Syntax highlighting ║
║ ║
║ TUI SHORTCUTS ║
║ @ Fuzzy file search ║
║ !command Run shell command ║
║ Ctrl+G External editor ║
║ Ctrl+L Clear screen ║
║ Enter Inject instructions (while running) ║
║ Esc Esc Edit previous messages ║
║ ║
║ EXEC MODE (CI/CD) ║
║ codex exec --sandbox workspace-write "task" Sandboxed auto ║
║ codex exec --json -o out.txt "task" JSON + file output ║
║ codex exec --output-schema s.json Structured output ║
║ codex exec resume --last "continue" Resume session ║
║ ║
║ MCP MANAGEMENT [EXPERIMENTAL] ║
║ codex mcp add <name> -- <cmd> Add STDIO server ║
║ codex mcp add <name> --url <u> Add HTTP server ║
║ codex mcp list List servers ║
║ codex mcp login <name> OAuth flow ║
║ codex mcp remove <name> Delete server ║
║ ║
║ PLUGINS ║
║ codex plugin marketplace add <src> Add marketplace ║
║ codex plugin marketplace upgrade Upgrade marketplaces ║
║ ║
║ CLOUD [EXPERIMENTAL] ║
║ codex cloud exec --env <ID> Start cloud task ║
║ codex cloud status <ID> Check task progress ║
║ codex cloud diff <ID> View task diff ║
║ codex cloud list List tasks ║
║ codex apply <TASK_ID> Apply cloud diff locally ║
║ ║
║ CONFIG FILES ║
║ ~/.codex/config.toml User config ║
║ .codex/config.toml Project config ║
║ ~/.codex/AGENTS.md Global instructions ║
║ AGENTS.md Project instructions ║
║ requirements.toml Enterprise policy constraints ║
║ ║
║ SANDBOX MODES ║
║ read-only Read files only, no mutations ║
║ workspace-write Read/write in workspace + /tmp ║
║ danger-full-access Full machine access ║
║ ║
║ APPROVAL POLICIES ║
║ untrusted Prompt for all mutations ║
║ on-request Prompt for boundary violations ║
║ never No prompts ║
║ ║
║ MODELS (April 2026) ║
║ gpt-5.5 Recommended default (400K in Codex) ║
║ gpt-5.5-pro Highest-effort GPT-5.5 tier ║
║ gpt-5.4 Prior flagship / fallback ║
║ gpt-5.4-mini Subagent work, 2x faster (400K) ║
║ gpt-5.3-codex Legacy coding specialist ║
║ ║
╚═══════════════════════════════════════════════════════════════╝
變更紀錄
| 日期 | 版本 | 變更內容 | 來源 |
|---|---|---|---|
| 2026-06-23 | 指南 v2.40:CLI v0.142.0 stable(6月22日,從 v0.142.0-alpha 線升級)。/usage額度:/usage現在會顯示並兌換已取得的使用限制重設額度,並提供確認、重試與更新後的可用狀態。/plugins重新整理:遠端 plugins 會分組到 OpenAI Curated、Workspace 與 Shared with me 區段,符合條件的回合也能推薦並安裝相關 plugins。Rollout token 預算:可設定的 token 預算會追蹤跨 agent threads 的用量、顯示剩餘預算提醒,並在用盡時中止回合。Multi-agent 委派模式:app-server clients 可在 thread 與 turn 層級將委派設定為 disabled、explicit-request-only 或 proactive。索引式 web search:新的索引式 web-search 模式允許即時搜尋,同時將直接頁面存取限制在伺服器核准的 URLs。時間:Codex 可接收排程的 UTC 時間提醒,並直接查詢目前時間,也包含透過 client 提供的 app-server clocks。修正:Linux TUI 在 Ctrl+Z 暫停/fg 恢復後的渲染;exec-server process 與 stdio MCP session 重新連線韌性;跨作業系統的 remote-environment path 保留;plugin 載入、安裝與 manifest 處理;parent-agent 對 subagent 錯誤的可見性;thread/list 與 thread/search 中以目標優先的 thread 持久化。(截至6月23日,最新 pre-release 是 v0.143.0-alpha.x,仍為 alpha,不追蹤。)來源:openai/codex releases與Codex Changelog。 |
104 | |
| 2026-06-18 | 指南 v2.39:CLI v0.141.0 stable(6月18日,從 v0.141.0-alpha 線升級)。加密遠端 executors:遠端 executors 現在使用已驗證、端對端加密的 Noise-relay channels,TLS 也接受 P-521 certificate signatures,以相容企業 proxy。跨平台遠端執行會保留 executor 原生的工作目錄與 shell。Windows sandbox:執行改善,包含自動認證復原。效能:大型、tool-heavy sessions 會快取 tool search,以降低延遲與記憶體用量;prompt-image 快取上限為 64 MiB。TUI:input prompts 可在閒置後透過倒數計時器自動解析;realtime clients 取得 speech-append 控制。(截至6月19日,最新 pre-release 是 v0.142.0-alpha.x,仍為 alpha,不追蹤。)來源:openai/codex releases與Codex Changelog。 | 103 | |
| 2026-06-16 | 指南 v2.38:CLI v0.140.0 stable(6月15日,從 v0.140.0-alpha 線升級)。/usage:新增每日、每週與累計帳號 token 活動檢視。Session 刪除:codex delete、/delete 與 app-server thread/delete 會在確認保護下永久移除 session。/import:可從 Claude Code 選擇性匯入 setup、project configuration 與近期 chats。統一 mentions:預設輸入 @ 會開啟同一個選單,涵蓋檔案、plugins 與 skills。Amazon Bedrock:受管理的 API-key authentication,外加 CLI 與 MCP OAuth credentials 的加密本機儲存。/goal 現在會在遠端 app-server sessions 中保留過大的文字、大型貼上區塊與 image attachments。移除:實驗性 /realtime 語音控制與音訊相依項已從 TUI 移除。修正:損毀的 SQLite state databases 會自動備份並從 rollout data 重建;/review 在有 queued guidance 時按下 Esc 不再當機;MCP 透過 transient-startup retries 與 disabled-server preservation 提升可靠性;遠端 plugin 解除安裝與需驗證 apps 的顯示;持久化「Don’t remind me」更新略過;non-TTY background commands 可用 Ctrl-C 中斷並保留輸出。維護:Git filesystem-monitor preservation,以及大型 repos 的 archive-lookup 加速。(截至6月16日,最新 pre-release 是 v0.141.0-alpha.x,仍為 alpha,不追蹤。)來源:openai/codex releases與Codex Changelog。 |
102 | |
| 2026-06-09 | 指南 v2.37:CLI v0.139.0 stable(6月9日,從 v0.139.0-alpha 線升級)。Code-mode web search:code mode 可直接呼叫獨立 web search(包含從巢狀 JavaScript tool calls 呼叫),並接收純文字結果。MCP schemas:tool/connector input schemas 現在會保留 oneOf/allOf 結構,以更好地保留大型 schema 結構並提升 MCP 相容性。codex doctor:新增 editor 與 pager environment details,並在 JSON output 中遮蔽敏感值。Plugins:codex plugin marketplace list --json 會揭露 plugin sources,並提供更快的 cached-catalog plugin listing。修正:codex resume --last / codex fork --last 會將 trailing args 視為 prompts(不是 session IDs);subagent MCP startup warnings 不再出現在錯誤的 thread context;image edits 會參照精確檔案路徑;TUI 中的 tilde URLs 會完整 linkify;thread resets(/new、/clear、/fork)會保留 cloud-managed requirements/feature flags;sandbox execution 會一致保留 approval decisions 並強制 proxy-only networking。維護:含 line tables 的獨立 symbol archives;rusty_v8 升級至 149.2.0。(截至6月9日,最新 pre-release 是 v0.140.0-alpha.x,仍為 alpha,不追蹤。)來源:openai/codex releases與Codex Changelog。 |
105 | |
| 2026-06-08 | 指南 v2.36:CLI v0.138.0 stable(6月8日,從 v0.138.0-alpha 線升級)。/app desktop handoff — /app 會將執行中的 CLI session 交接給 macOS 與 Windows 上的 desktop app。本機 image paths 暴露給 models — model 可直接參照本機 image file paths。更彈性的 reasoning-effort selection。 Plugins:透過結構化 JSON output 增強 automation。來源:openai/codex releases與Codex Changelog。 |
106 | |
| 2026-06-04 | 指南 v2.35:CLI v0.137.0 stable(6月4日,從6月3日首次出現的 alpha 線升級)。TUI:controls 支援 F13–F24 keybindings;searchable menus 可接受 paste;提供 compact reasoning-only status/title item。Enterprise/admin:流程會顯示 monthly credit limits 與 cloud-managed config bundles。Remote control:clients 可啟動 pairing 並管理 controller grants。Plugins:workflows 取得 machine-readable JSON output 與 cached remote catalog suggestions。Tools:hosted web 與 image tools 可用於更多 code-mode flows;獨立 web searches 可平行執行。Multi-agent:v2 runtime 改善,提供更清楚的 follow-up handling 與 metadata defaults。修正:取消 prompt 會還原 draft、attachments 與 collaboration mode;macOS app launch 與 Windows SQLite startup reliability;plugin manifest ordering 與 deduplication;permission requests 會遵循 environment identity。來源:openai/codex releases與Codex Changelog。 | 107 | |
| 2026-06-02 | 指南 v2.34:CLI v0.136.0 stable(6月1日)。Session archiving:TUI 中的 /archive,以及 codex archive / codex unarchive CLI commands;archived session 在還原前會受到保護,無法 resume 或 fork。TUI markdown:web links 會透過 OSC 8 metadata 保持可點擊,過擠的 tables 會退回可讀的 key/value records,且不遺失 link targets。App-server:codex app-server --stdio 會以 stdio mode 啟動,供 editor/host integrations 使用;使用 initial-turns pages 恢復 threads;顯示更豐富的 MCP server status。Remote/security:remote execution setup 會接受 CODEX_API_KEY,供已核准 OpenAI hosts 使用;remote-control websockets 改用短效 server tokens,而非 ChatGPT access tokens;/diff 被禁止執行 repository-provided Git helpers(command-safety 修正);ChatGPT auth 會重新整理即將到期的 tokens,並在 refresh tokens 被重複使用時提示重新登入;Bedrock auth 會 fallback 到 AWS_REGION/AWS_DEFAULT_REGION。Windows(alpha):提供 administrators 使用的 codex sandbox setup --elevated provisioning path。Image generation:透過 native image-artifact completion pipeline,提供 feature-gated standalone image-generation extension。註:昨天的檢查仍將此標為「僅 v0.136.0 alpha」;它已於6月1日升級為 stable。來源:openai/codex releases與Codex Changelog。 |
108 | |
| 2026-05-28 | Guide v2.33:CLI v0.134.0 stable + v0.135.0 release。v0.134.0(5月26日):新增跨本機對話記錄搜尋,支援不區分大小寫的內容比對與結果預覽;讓--profile成為CLI、TUI權限與sandbox流程的主要profile選擇器,並透過遷移指引拒絕舊版profile設定;改進MCP設定,支援每個伺服器的環境目標設定,以及streamable HTTP伺服器的OAuth選項;透過保留本機$ref/$defs並壓縮過大的schema,讓connector tool schema更可靠;當唯讀MCP工具宣告readOnlyHint時,可並行執行;為extension工具加入更豐富的extension/hook脈絡,包括對話記錄。錯誤修正:遠端可靠性(過期exec-server websocket重新連線、遠端重試);透過virtual terminal mode恢復Windows TUI渲染損毀;針對credit與spend-cap失敗提供workspace專屬用量限制訊息;skills支援共用plugin層級icon資產;同步auto-review runtime設定時保留作用中的permission profile中繼資料;Node型工具遵循Codex的受管理網路proxy env。v0.135.0(5月28日):codex doctor回報更豐富的環境、Git、terminal、app-server與thread清單;當TUI透過遠端連線時,/status會顯示遠端連線細節與伺服器版本;vim mode新增text-object編輯、改善word/line-end行為,並支援可設定的interrupt-turn;/permissions理解具名permission profiles並顯示自訂profile;封裝版Codex build會在支援的macOS與Linux上探索並使用內建修補版zsh helper;Python SDK針對thread與turn APIs提供友善的Sandbox預設。錯誤修正:TUI markdown表格與多行清單以更好的欄寬調整與app-mention處理呈現,閱讀性更高;改善macOS與Zellij上的TUI輸出穩定性(不再有stderr/composer損毀或raw-output外洩);slash-command補完會保留含inline arguments命令的草稿文字;較舊的tmux/iTerm control-mode session保留正常的Ctrl-C處理;@ app mentions會排除無法存取/停用的app,而非提供無法使用的$建議;resume流程可在要求時包含非互動式exec session,並遵循cwd覆寫。來源:Codex Changelog與openai/codex releases。 |
109 | |
| 2026-05-26 | Guide v2.31:latest-line複查。GitHub releases仍將0.134.0-alpha.1至0.134.0-alpha.3列為prerelease,而0.133.0仍是最新stable CLI;npm latest仍回報0.133.0,time.modified為2026-05-23T01:26:52.705Z,本機codex --version傳回codex-cli 0.133.0。功能指引與5月25日檢查相比沒有變更。 |
101 | |
| 2026-05-25 | Guide v2.30:latest-line與app-context檢查。GitHub releases將0.134.0-alpha.1至0.134.0-alpha.3列為prerelease,而0.133.0仍是最新stable CLI;npm latest也回報0.133.0,time.modified為2026-05-23T01:26:52.705Z,本機codex --version傳回codex-cli 0.133.0。加入5月21日Codex app更新:適用於最前方Mac視窗的Appshots、Goal mode在app/IDE/CLI全面GA、app內瀏覽器註解/browser-use改進、鎖定的Computer Use,以及Enterprise/Edu的analytics與plugin-sharing狀態說明。修正「四個介面」偏移為五個介面,並依目前codex features list格式更新feature flags範例。 |
99 100 101 | |
| 2026-05-21 | Guide v2.29:CLI v0.133.0 stable。npm套件中繼資料將@openai/codex最新版本列為0.133.0;本機codex --version仍為codex-cli 0.131.0。新增v0.132.0與v0.133.0差異:goals預設啟用並具備專用儲存與進度追蹤、可在foreground準備就緒的codex remote-control、permission-profile list APIs/繼承/受管理requirements.toml/runtime refresh/Windows sandbox整合、具marketplace感知的plugin探索並顯示已安裝版本與遠端collections、subagents/tools/turn metadata/async approvals的extension lifecycle events、Python SDK一級auth、更豐富的Python TurnResult、codex exec resume --output-schema、更快的TUI啟動、auth支援的remote executor註冊,以及app-server image-fidelity保留。 |
97 98 | |
| 2026-05-18 | Guide v2.28:CLI v0.131.0 stable。OpenAI的Codex changelog與npm套件中繼資料現在將@openai/codex最新版本列為0.131.0。新增codex doctor、統一@ mention搜尋、marketplace CLI commands、具版本感知的plugin sharing、預設啟用的plugin hooks、daemon管理的remote-control/runtime啟用停用、registry支援的remote environments、更豐富的TUI session/status controls、responsive Markdown tables、openai-codex Python SDK更新、更安全的local-state啟動、Windows sandbox強化,以及state/Git/auth可靠性修正。本輪本機驗證:codex --version傳回codex-cli 0.131.0;npm view @openai/codex version dist-tags.latest time.modified --json傳回latest 0.131.0,time.modified為2026-05-18T22:00:51.726Z。 |
96 | |
| 2026-05-15 | Guide v2.27:security-hygiene與latest-line維護檢查。本機codex --version傳回codex-cli 0.130.0;codex features list顯示hooks與plugins為stable/enabled,而remote_control仍在開發中。stable guide指引仍固定於CLI v0.130.0。新增可公開揭露的安全指引,將命令輸出、session transcripts、shell snapshots、logs、helper scripts與刻意設置的secret stores視為各自獨立的audit surfaces。 |
91 95 | |
| 2026-05-13 | Guide v2.26:latest-line維護檢查。本機codex --version傳回codex-cli 0.130.0;stable guide指引仍固定於CLI v0.130.0。v0.131.0系列已到alpha.9,但仍為prerelease,未提升到指南標題或TL;DR。94 |
91 94 | |
| 2026-05-09 | Guide v2.25:CLI v0.130.0 stable(2026年5月8日23:09 UTC)。新增codex remote-control頂層命令,用於headless app-server控制(#21424);plugin詳細資訊顯示bundled hooks,plugin sharing揭露link metadata、discoverability controls與更新後的share settings(#21447、#21495、#21637);app-server thread pagination支援unloaded / summary / full turn views(#21566);透過AWS aws login console-login credentials支援Bedrock auth(#21623);view_image在multi-environment sessions中透過選定環境解析(#21143);running threads可即時重新整理app-server config(#21187);從codex exec啟動banner移除「research preview」措辭(#21683);可設定的OpenTelemetry trace metadata與更豐富的review/feedback analytics(#21556、#18747、#21434、#21498);Linux sandbox啟動強化,Windows sandbox授權desktop runtime binary cache(#21564)。v0.131.0 alpha線正在進行中(5月9日的alpha.1、alpha.2、alpha.4,之後5月12日為alpha.9)。僅註腳:GPT-5.5 Instant於2026年5月5日推出至free tier。92 |
91 | |
| 2026-05-08 | Guide v2.24:Codex for Chrome(2026年5月7日)。新增Chrome extension,作為繼CLI、desktop app、IDE extension與cloud之後的第五個Codex介面。此extension可在背景跨分頁平行運作,而不接管瀏覽器,並支援依網站設定控制allow-list。更新Key Takeaways與Core Interaction Surfaces,從四個介面改為五個介面。 | 90 | |
| 2026-05-07 | Guide v2.23:CLI v0.129.0 stable(2026年5月7日17:02 UTC)。新增composer中的modal Vim編輯(/vim與可設定的default-mode)、重新設計的TUI workflow picker(更容易resume/fork、raw scrollback mode)、TUI內/hooks browser、具theme感知的status line並可選擇顯示PR與branch-change摘要、plugin管理升級(workspace sharing、share access controls、source filtering、marketplace operations)、/goal lifecycle變更(experimental goals在resume後保持暫停,除非重新選擇加入)、Linux sandbox啟動強化、Windows sandbox可靠性改進,以及Bubblewrap升級至0.11.2並包含上游安全修補。另記錄2026年5月用量限制提升(Codex Plus 5小時限制提高25倍,$100/月級距加倍,兩者皆至2026年5月31日)。 |
89 | |
| 2026-05-05 | Guide v2.22:將目前指引同步至CLI v0.128.0。新增持久化/goal workflows、codex update、可設定的TUI keymaps、明確的permission-profile指引,以及目前codex plugin marketplace命令語法。修正過時指引:標示js_repl已移除、以明確sandbox/approval flags或permissions profiles取代--full-auto範例,並依OpenAI的2026年7月23日停用表標註舊版GPT-5.2/5.1 Codex models。 |
86 87 88 | |
| 2026-04-24 | Guide v2.21:GPT-5.5 發表(2026年4月23日至24日) + CLI v0.122.0–v0.125.0。GPT-5.5 是 OpenAI 的新旗艦模型 — Codex 中提供 400K context window(API 中為 1M),輸入/輸出每 MTok 為 $5/$30(為 GPT-5.4 費率的 2 倍,但在 token 效率提升後,實際增幅約 20%)。基準測試:82.7% Terminal-Bench 2.0(SOTA)、84.9% GDPval、78.7% OSWorld-Verified、98.0% Tau2-bench Telecom。可在 Codex CLI/web/desktop 與 API 使用;建議作為多數 Codex 工作的預設模型。ChatGPT Plus/Pro/Business/Enterprise/Edu/Go 於4月23日推出;API 於4月24日推出。90 多個新 plugin 合作夥伴,包含 Atlassian Rovo、CircleCI、CodeRabbit、GitLab Issues、Microsoft Suite、Neon by Databricks、Remotion、Render 與 Superpowers。CLI v0.122.0:檔案系統 deny-read glob policies + managed deny-read requirements + 平台 sandbox 強制執行 + 隔離的 codex exec 執行會忽略使用者設定/規則;tool discovery 與 image generation 預設啟用;為 MCP 與 js_repl 提供更高細節的影像處理與 original-detail metadata;app-server 跨用戶端解決 stale-prompt;恢復/分叉的 threads 會立即重播 token usage;remote-control 啟動可容忍缺少 ChatGPT auth;MCP 啟動取消可再次透過 app-server sessions 運作;內部拆分為 codex-core-plugins。CLI v0.123.0:內建 amazon-bedrock model provider,支援 AWS profile;/mcp verbose 可取得完整 MCP diagnostics、resources 與 resource templates(一般 /mcp 維持快速);plugin MCP 載入可接受 .mcp.json 中的 mcpServers 與頂層 server maps;realtime handoffs 會將 transcript deltas 傳遞給 background agents(並提供明確的 silent-stay option);針對 remote environments 的 host-specific remote_sandbox_config;更新內建 model metadata(當時預設為 gpt-5.4)。修正:rollback 後的 /copy、shell command 執行期間的 queued text、VS Code WSL Unicode/dead-key input、stale proxy env 還原、codex exec 繼承根層 shared flags、TUI 中外洩的 review prompts。CLI v0.124.0:TUI 快速 reasoning controls(Alt+, 降低 / Alt+. 提高);接受 model upgrades 會將 reasoning 重設為新模型的預設值;app-server sessions 可管理多個 environments,並支援每回合選擇 environment + working-directory;針對 OpenAI-compatible providers 的一級 Amazon Bedrock 支援(AWS SigV4 signing、credential auth);remote plugin marketplaces 具備可靠的詳細資料查詢與更大的結果頁面;hooks 現已穩定 — 可在 config.toml 與 requirements.toml 內 inline 設定,並觀察 MCP tools + apply_patch + 長時間執行的 Bash sessions;符合資格的 ChatGPT plans 預設使用 Fast service tier,除非明確退出。修正:Cloudflare cookies 會在已核准的 ChatGPT hosts 間保留、負載下的 websocket 可靠性、side conversations 間的 permission-mode drift、wait_agent mailbox-queue timing、本機 stdio MCP relative-command path resolution、startup managed-config edge cases。CLI v0.125.0(4月24日):app-server Unix socket transport、支援分頁的 resume/fork、sticky environments、remote thread config/store plumbing;app-server plugin management 可安裝 remote plugins 並升級已設定的 marketplaces;permission profiles 可 round-trip 於 TUI sessions、user turns、MCP sandbox state、shell escalation 與 app-server APIs;model providers 負責 model discovery,並將 AWS/Bedrock account state 暴露給 app clients;codex exec --json 會回報 reasoning-token usage;rollout tracing 會記錄 tool/code-mode/session/multi-agent 關係,並提供 debug reducer command。修正:/review interrupt 不再卡住 TUI、exec-server output/stream-closure handling、app-server 會尊重明確 untrusted 的 project config、notification bursts 期間的 websocket disconnection、Windows sandbox startup 與 background process handling、thread limits 與 agent paths 的 config-schema validation。 |
83 84 85 | |
| 2026-04-16 | Guide v2.20:CLI v0.121.0(2026年4月15日)。Plugin Marketplace(codex marketplace add <source>),支援 GitHub、git URL、local-dir 與 marketplace.json source types。TUI reverse history search(Ctrl+R)與 slash-command recall。TUI 中的 Memories menu,支援重設/刪除;memory reset 現在會保留過往 rollouts。Phase-2 memory consolidation model 升級至 GPT-5.4。採用 Bubblewrap sandboxing 的安全 devcontainer profile(僅 WSL2;拒絕 WSL1)。macOS sandbox:Unix socket allowlists 與 private DNS 已解除封鎖。danger-full-access denylist-only mode 已移除 — full-access 現為二元狀態。MCP tools 以 namespaces 註冊;supports_parallel_tool_calls flag 已完整接通;sandbox-state metadata 會流經 MCP tool metadata。Guardian review sessions 會停用 hooks。 狀態列加入 context-percent indicator;CLI update announcement 會顯示新版本。修正 Windows resume --last 的 verbatim paths。新增用於本機 thread lookups 的 codex-thread-store interface。 |
82 | |
| 2026-04-13 | Guide v2.19:CLI v0.119.0–v0.120.0。Realtime voice sessions(V2 WebRTC,transport 可設定)。MCP Apps 支援 resource reads、elicitations、file uploads。codex exec-server 實驗功能。可用 ID 或名稱 /resume。Ctrl+O 複製最新回應。TUI 中的 hook activity 改進。SessionStart hooks 可區分 /clear。 |
80 81 | |
| 2026-04-04 | Guide v2.18:更新 Business pricing($25/mo → 年繳 $20)。為 Business/Enterprise 新增 Codex-only pay-as-you-go seats。 | 79 | |
| 2026-04-01 | Guide v2.17 | 更新至 CLI v0.118.0:Windows proxy-only sandbox networking(作業系統層級 egress)、ChatGPT device-code auth flow、codex exec prompt-plus-stdin、custom providers 的 dynamic bearer token refresh。首次建立時保護 .codex 檔案。修正 Linux bwrap PATH discovery。修正 TUI app-server regressions(hook replay、/copy、/resume <name>、/agent、skills picker scrolling)。MCP 啟動穩定性(更長的 startup window、warning display)。Windows apply_patch ACL 修正。將 GPT-5.4 mini 加入 model table(400K context、30% GPT-5.4 quota、快 2 倍)。新增 Codex Security section(research preview、context-aware vulnerability detection)。 |
78 76 77 |
| 2026-03-31 | CLI 0.118.0 | Windows 透過作業系統層級 egress rules 提供 proxy-only sandbox networking、app-server clients 的 ChatGPT device-code auth flow、codex exec prompt-plus-stdin workflow(piped input + separate prompt)、custom model providers 的 dynamic bearer token fetch/refresh。修正:首次建立時的 .codex 檔案保護、Linux bwrap PATH discovery、TUI app-server regressions(hook notification replay、/copy、/resume <name>、/agent threads、skills picker scrolling)、MCP 啟動穩定性(更長的 startup window、failure warnings)、Windows apply_patch redundant writable-root ACL churn。 |
78 |
| 2026-03-17 | – | GPT-5.4 mini 發表:400K context、每 MTok $0.75/$4.50、30% GPT-5.4 quota、快 2 倍。可於 Codex app、CLI、IDE extension 與 web 使用。特別適合 subagent/parallel subtask delegation。 | 76 |
| 2026-03-06 | – | Codex Security research preview:透過 Codex web 為 Pro/Enterprise/Business/Edu 提供 context-aware application security review。已掃描 1.2M commits,發現 10,561 個 high-severity findings,並在 OpenSSH/GnuTLS/Chromium 指派 14 個 CVEs。 | 77 |
| 2026-03-30 | Guide v2.16 | 更新至 CLI v0.117.0:一級 plugins(啟動時 product-scoped sync、/plugins browser、安裝/移除)、sub-agents v2(path-based addresses、structured inter-agent messaging、agent listing)、/title terminal-title picker、預設啟用 app-server TUI(! shell commands、filesystem watch、具 bearer auth 的 remote WebSocket、跨 sessions 的 prompt history recall)、image workflow 改進(view_image 回傳 URLs、generated images 可重新開啟、history 可在 resume 後保留)、移除 legacy artifact tool(退役 read_file 與 grep_files)、針對較舊 distros 的 Linux sandbox 改進、Windows restricted-token sandbox 改進。 |
75 |
| 2026-03-28 | CLI 0.117.0 | 一級 plugins,啟動時提供 product-scoped sync 與 /plugins TUI browser。Sub-agents v2:path-based addresses(/root/agent_a)、structured inter-agent messaging、agent listing。TUI 與 app-server TUI 中的 /title terminal-title picker。App-server clients:! shell commands、filesystem watch、具 bearer auth 的 remote WebSocket。Image workflows:view_image 回傳 URLs、generated images 可重新開啟、history 可在 resume 後保留。App-server TUI 可跨 sessions recall prompt history。App-server TUI 預設啟用。移除 legacy artifact tool;退役舊的 read_file 與 grep_files。針對較舊 distros 的 Linux sandbox 改進。Windows restricted-token sandbox 改進。 |
75 |
| 2026-03-21 | Guide v2.15 | 更新至CLI v0.116.0:UserPromptSubmit hook事件(共5個)、app-server TUI中的ChatGPT裝置碼驗證、更順暢的plugin安裝流程,支援建議allowlist與遠端同步、realtime工作階段會帶入近期thread脈絡、降低音訊自我中斷。修正:WebSocket第一輪延遲、遠端resume/fork的對話歷史、符號連結checkout/AppArmor上的Linux sandbox、agent job完成時的競態條件。 |
74 |
| 2026-03-19 | CLI 0.116.0 | UserPromptSubmit hook(執行前封鎖或補強prompt)、TUI中的ChatGPT裝置碼驗證、透過allowlist/遠端同步讓plugin設定更順暢、realtime工作階段帶入近期thread脈絡、降低音訊自我中斷。修正:WebSocket預熱造成的第一輪卡住、遠端resume/fork的對話歷史、符號連結checkout/AppArmor上的Linux sandbox啟動、agent job完成競態。合併77個PR。 |
74 |
| 2026-03-18 | Guide v2.14 | 更新至CLI v0.115.0:透過view_image與codex.emitImage進行完整解析度影像檢查、js_repl公開codex.cwd/codex.homeDir、realtime WebSocket轉錄模式、app-server v2檔案系統RPC、含guardian subagent的Smart Approvals(approvals_reviewer = "guardian_subagent")、Responses API tool-search。錯誤修正:subagent sandbox繼承、js_repl U+2028/U+2029卡住、TUI退出停滯、使用codex exec --profile時保留profile設定、MCP/elicitation改善、HTTP/1 CONNECT proxy。 |
73 |
| 2026-03-16 | CLI 0.115.0 | 透過view_image與codex.emitImage(..., detail: "original")進行完整解析度影像檢查、js_repl公開codex.cwd與codex.homeDir並提供持久化tool參照、realtime WebSocket工作階段支援轉錄模式與v2 handoff、app-server v2檔案系統RPC(讀取/寫入/複製/目錄操作/路徑監看)、Smart Approvals會透過guardian subagent路由、app整合使用Responses API tool-search並具備fallback。修正:產生的subagents更可靠地繼承sandbox/network規則、js_repl不再因U+2028/U+2029卡住、解決TUI退出停滯、使用codex exec --profile時保留profile設定、改善MCP/elicitation流程、本機network proxy以HTTP/1提供CONNECT。 |
73 |
| 2026-03-13 | Guide v2.13 | App v26.312:可自訂theme(色彩+字型)、重新設計Automations,支援本機/worktree執行與每次執行的reasoning層級。新增winget安裝方式。新增GPT-5.1淘汰註記(3月11日——已自ChatGPT移除,並自動遷移至GPT-5.3/5.4)。 | 71 72 |
| 2026-03-12 | App v26.312 | Settings中提供含色彩控制與字型選擇的可自訂theme、重新設計Automations介面,支援本機或worktree執行模式與自訂reasoning層級,並改善效能。 | 72 |
| 2026-03-11 | Guide v2.12 | 更新至CLI v0.114.0:實驗性hooks引擎(SessionStart、Stop事件)、實驗性code mode、health check endpoints、停用system skills設定、handoff transcript脈絡、強化$ mention picker。更新Hooks章節,納入4個事件。修正Windows Desktop App章節(現已推出)。將Quick Reference Card模型更新至2026年3月。 | 70 |
| 2026-03-11 | CLI 0.114.0 | 用於隔離coding工作流程的實驗性code mode、含SessionStart與Stop事件的實驗性hooks引擎、WebSocket app-server health check endpoints(/readyz、/healthz)、停用內建system skills的config開關、handoffs會攜帶realtime transcript脈絡、強化$ mention picker並顯示skill/app/plugin標籤。錯誤修正:Linux tmux當機、重新開啟的threads卡在執行中、舊版permission處理、approval流程持久化。 | 70 |
| 2026-03-10 | Guide v2.11 | 更新至CLI v0.113.0:@plugin mentions(v0.112.0)、request_permissions tool、permission-profile config語言、plugin marketplace擴充(v0.113.0)。新增@plugin Mentions、Plugin Marketplace、Runtime Permission Requests與Permission-Profile Config Language章節。 | 68 69 |
| 2026-03-10 | CLI 0.113.0 | 內建request_permissions tool可用於runtime permission requests、plugin marketplace discovery提供更豐富的metadata/安裝時auth檢查/uninstall endpoint、app-server streaming stdin/stdout/stderr並支援TTY/PTY、permission-profile config語言可分離filesystem/network sandbox政策、image generation會儲存至CWD、web search settings具備完整tool config、強化network proxy政策並拒絕全域萬用字元網域 | 69 |
| 2026-03-08 | CLI 0.112.0 | @plugin mentions可在chat中參照plugins並自動納入脈絡、TUI picker新增model-selection介面、可執行permission profiles會合併至每輪sandbox policy以供zsh-fork skill執行、JS REPL狀態處理修正(失敗cell後仍保留bindings)、app-server websocket關閉時將SIGTERM視同Ctrl-C、Linux bubblewrap一律unshare user namespace、macOS sandbox network/unix-socket處理改善 | 68 |
| 2026-03-06 | Guide v2.10 | 更新至CLI v0.111.0:GPT-5.4作為建議model(1M context)、fast mode預設啟用、plugin system(v0.110.0)、js_repl dynamic imports、持久化/fast toggle、Windows installer。Codex App for Windows(v26.304)。透過Cerebras合作推出GPT-5.3-Codex-Spark。更新model表格、流程圖、profiles。新增Plugins章節。 | 64 65 66 67 |
| 2026-03-05 | CLI 0.111.0 | fast mode預設啟用、js_repl支援本機檔案dynamic imports、工作階段開始時進行plugin discovery、支援image workflow、thread resumption會保留git脈絡 | 65 |
| 2026-03-05 | – | GPT-5.4推出:旗艦frontier model、1M context、原生computer use,並可於所有Codex介面使用 | 64 |
| 2026-03-05 | CLI 0.110.0 | skills/MCP/app connectors的plugin system、multi-agent approval prompts、持久化/fast toggle、workspace範圍memory寫入、Windows installer script | 65 |
| 2026-03-04 | App v26.304 | Codex App for Windows:原生PowerShell支援、原生sandbox、無需WSL即可使用skills/automations/worktrees | 66 |
| 2026-03-03 | App v26.303 | Worktree auto-cleanup toggle、Local-to-Worktree handoff支援、明確的英文語言選項 | 66 |
| 2026-03-02 | Guide v2.9 | 更新至CLI v0.107.0:將thread fork至sub-agents、realtime voice裝置選擇、可設定memories並支援codex debug clear-memories、multimodal custom tool output。新增App v26.226:composer中的MCP shortcuts、review comments中的@mentions。 |
62 63 |
| 2026-03-02 | CLI 0.107.0 | 將thread fork至sub-agents、realtime voice工作階段支援麥克風/喇叭裝置選擇、custom tools multimodal output、可設定memories+codex debug clear-memories、錯誤修正 |
62 |
| 2026-02-28 | Guide v2.8 | 更新至CLI v0.106.0:新增direct install script、zsh-fork sandbox bypass修正、約1M字元input上限、Linux /dev檔案系統、彈性approval controls、JS REPL升級至/experimental(Node 22.22.0+)、以diff為基礎的memory forgetting、TUI syntax highlighting+/theme、/copy、/clear、Ctrl-L、voice transcription、Default mode中的spawn_agents_on_csv、request_user_input。新增v0.105.0與v0.106.0 changelog項目。 | 60 61 |
| 2026-02-26 | CLI 0.106.0 | Direct install script、js_repl升級至/experimental且最低需求為Node 22.22.0、Default mode中的request_user_input、API使用者可在CLI model list看到5.3-codex、具usage-aware selection的diff-based memory forgetting、zsh-fork sandbox bypass修正、約1M字元input上限、改善TUI file-link rendering、修正sub-agents的Ctrl-C處理 | 60 |
| 2026-02-25 | CLI 0.105.0 | TUI會搭配/theme picker對fenced code blocks與diffs做syntax-highlight、voice transcription(空白鍵dictation,實驗性)、spawn_agents_on_csv用於multi-agent fanout並顯示進度/ETA、/copy /clear Ctrl-L commands、彈性approval controls(額外sandbox permissions、細粒度rejection)、可點擊的換行links、供sandboxed commands使用的Linux /dev檔案系統、js_repl錯誤回報改善 | 61 |
| 2026-02-24 | Guide v2.7 | 擴充Access/Pricing章節:新增Free/Go促銷tier、付費方案2倍rate limits、各方案usage limits(5小時window)、credit costs表格。新增allow_login_shell config key。 |
51 |
| 2026-02-22 | Guide v2.6 | 新增缺漏的config keys:features.multi_agent、features.apply_patch_freeform、features.search_tool、agents.*(multi-agent roles)、model_context_window、model_auto_compact_token_limit、mcp_oauth_callback_port、mcp_oauth_credentials_store、notify。新增App v26.217 changelog項目。 |
50 |
| 2026-02-19 | Guide v2.5 | 將版本參照更新至CLI 0.104.0、新增v0.103.0與v0.104.0 changelog項目、新增WS_PROXY/WSS_PROXY proxy支援、不同approval IDs、commit co-author attribution,並以command_attribution取代已移除的remote_modelsfeature flag。 |
— |
| 2026-02-18 | CLI 0.104.0 | WS_PROXY/WSS_PROXY WebSocket proxy 支援、多步驟命令使用不同 approval ID、thread 封存/取消封存通知 | 49 |
| 2026-02-17 | App v26.217 | 拖放重新排序佇列訊息、model 降級警告、改良 fuzzy 檔案搜尋,重啟後可復原附件 | 50 |
| 2026-02-17 | CLI 0.103.0 | 透過 prepare-commit-msg hook 加入 commit 共同作者歸屬(可由 command_attribution 設定)、更完整的 app 列表 metadata/branding、移除 remote_models feature flag |
48 |
| 2026-02-17 | Guide v2.4 | 更新所有 CLI 0.102.0 版本參照,新增 v0.102.0 changelog 條目與註腳,並以可設定的 multi-agent 角色更新 sub-agents 註記。 | — |
| 2026-02-17 | CLI 0.102.0 | 統一 permissions flow、結構化 network approvals、可自訂 multi-agent 角色、model reroute 通知、js_repl 穩定性修正 | 47 |
| 2026-02-16 | Guide v2.3 | 修正 migration 表格:hooks 現已存在(v0.99.0+)、承認 subagents(最多 6 個)、model 清單完整。新增專屬 Hooks 區段(AfterAgent、AfterToolUse、migration patterns)。修正 Recipe 5 幽靈命令(cloud start→cloud exec、cloud pull→apply)。修正 codex auth→codex login。Windows sandbox 從 Experimental 升格。Linux Bubblewrap 現已 vendored/內建。新增 minimal reasoning effort 等級。擴充 memory 區段(v0.101.0 refinements、memory vs AGENTS.md)。更新 AGENTS.md 採用者清單(60,000+ 個專案、Linux Foundation governance)。更新 Copilot migration 表格。修正 [EXPERIMENTAL] 大小寫一致性。新增 ReadOnlyAccess policy 文件、JS REPL Runtime 區段、production Deploy skill 範例,擴充 cost 區段(隱藏 token overhead、team cost management)。標記 20 個未標記的 code blocks。驗證全部 30 個 ToC anchors。評估後修正:/permissions 術語更正(approval mode→approval policy)、重複的「Project Trust」標題重新命名、chat/completions deprecation 語氣改為保留、OpenTelemetry 區段加入 config 範例、migration 中「harder to escape」的說法改得更精確。 |
Deliberation audit |
| 2026-02-16 | Guide v2.2 | 在 changelog 新增 19 個歷史 CLI 里程碑版本(v0.2.0–v0.91.0)。將大量共用的 24 citation 改為 20 個個別 release footnotes(35–59)。新增 59 Apache 2.0 license citation。新增 5 citation 至 codex-linux-sandbox 參照。新增 21 citation 至 MDM preference domain。更新 6 Seatbelt 註記,說明 bot-blocking。新增無法驗證 OpenAI blog URLs 的註記。註腳總數:56(原為 36)。 | Deliberation audit |
| 2026-02-15 | Guide v2.1 | 修正 Enterprise 區段(managed-admin-config.toml → requirements.toml,並使用已驗證 TOML keys)、將 272K context 明確標示為 input window 並加上 citation、新增 6 Seatbelt citation URL、新增 Key Takeaways 區塊、修正 style violations、縮短 meta description、擴充 AGENTS.md 採用者清單。 | Blog evaluator audit |
| 2026-02-14 | Guide v2 | 重大修訂:由 Codex 驗證的修正,涵蓋 models(272K context)、config keys、feature flags、pricing、enterprise config、CI/CD action、SDK API、MCP options、codex exec flags、desktop app features、migration comparisons。移除無法驗證的 claims。 | Self-review |
| 2026-02-12 | CLI 0.101.0 | Model resolution 改良、memory refinements、穩定性 | 35 |
| 2026-02-12 | CLI 0.100.0 | 實驗性 JS REPL、多重 rate limits、WebSocket transport、memory commands、強化 sandbox | 36 |
| 2026-02-12 | App v260212 | Conversation forking、浮動 pop-out window、Windows alpha | 17 |
| 2026-02-12 | – | GPT-5.3-Codex-Spark 發表(低延遲互動變體) | 25 |
| 2026-02-11 | CLI 0.99.0 | Concurrent shell commands、/statusline、可排序 resume picker、GIF/WebP 支援、shell snapshotting |
37 |
| 2026-02-06 | CLI 0.98.0 | GPT-5.3-Codex 支援、steer mode 穩定並成為預設、model switching 修正 | 38 |
| 2026-02-06 | CLI 0.97.0 | 「Allow and remember」MCP approvals、live skill detection、/config diagnostics、memory plumbing |
39 |
| 2026-02-06 | CLI 0.96.0 | Async thread/compact v2、WebSocket rate limits、非 Windows 的 unified_exec、config provenance | 40 |
| 2026-02-06 | CLI 0.95.0 | codex app command、personal skills、parallel shell tools、git hardening |
41 |
| 2026-02-05 | – | GPT-5.3-Codex 發表——統一 model、速度快 25%、端到端 computer operation | 26 |
| 2026-02-02 | – | Codex Desktop App 發表(macOS)——multi-tasking、worktrees、automations | 16 |
| 2026-01-30 | CLI 0.94.0 | Plan mode 預設、personality 穩定、skills 來自 .agents/skills、runtime metrics |
42 |
| 2026-01-29 | CLI 0.93.0 | SOCKS5 proxy、plan mode streaming、/apps、smart approvals 預設、SQLite logs |
43 |
| 2026-01-29 | CLI 0.92.0 | API v2 threads、thread filtering、MCP OAuth scopes、multi-agent collaboration | 44 |
| 2026-01-25 | CLI 0.91.0 | 將 max sub-agents 從 12 降至 6,以提供更嚴謹的 resource guardrails | 45 |
| 2026-01-21 | CLI 0.88.0 | Device-code auth fallback、collaboration modes、/fork、remote models、model_personality config |
46 |
| 2026-01-06 | CLI 0.78.0 | Ctrl+G external editor、project-aware config layering、macOS MDM config、TUI2 transcript nav、.dmg installers |
52 |
| 2025-12-18 | – | GPT-5.2-Codex 發表——context compaction、refactors/migrations、cybersecurity | 27 |
| 2025-12-09 | CLI 0.66.0 | Exec policy system(TUI whitelisting、sandbox denial amendments)、CRLF preserving、Linux Sigstore signing | 53 |
| 2025-11-19 | – | GPT-5.1-Codex-Max——multi-window compaction、Windows training、thinking tokens 減少 30% | 28 |
| 2025-11-19 | CLI 0.59.0 | Native compaction、tool output limit 提高到 10K tokens、Windows Agent mode sandbox、/status 中顯示 credits |
54 |
| 2025-10-25 | CLI 0.50.0 | /feedback diagnostics、sandbox violation risk assessment、MCP startup 改良、env var redaction |
55 |
| 2025-10-06 | – | Codex 於 DevDay GA——Slack integration、SDK、admin tools | 29 |
| 2025-10-06 | CLI 0.45.0 | Breaking: codex login --api-key → --with-api-key(stdin)。OAuth MCP auth、parallel tool calls、pulsing dot UI |
56 |
| 2025-09-23 | – | GPT-5-Codex + IDE extension + CLI revamped——images、web search、code review | 30 |
| 2025-09-23 | CLI 0.40.0 | Default model → gpt-5-codex、220K tokens 自動 compaction、/review commands、git undo、Windows binary support |
57 |
| 2025-06-30 | CLI 0.2.0 | 首個 Rust binary release——提供 macOS(aarch64/x86_64)與 Linux(gnu/musl)的 pre-built binaries、codex-exec 與 codex-linux-sandbox tools |
58 |
| 2025-06 | – | 宣布 Rust rewrite(「Codex CLI is Going Native」) | 31 |
| 2025-06-03 | – | Plus user expansion、cloud 網際網路 access、PR updates、voice dictation | 32 |
| 2025-05-16 | – | Codex Cloud 發表——搭載 codex-1 model 的 cloud agent、GitHub PR creation | 33 |
| 2025-04-16 | – | Codex CLI open-source launch(Apache 2.0、TypeScript、codex-mini-latest)59 | 1 |
| — |
參考資料
OpenAI blog URL注意事項:參考文獻16、25–30、33、64、66、67、76與77連至
openai.com/index/blog posts;由於 Cloudflare bot protection,這些連結會對自動化存取回傳 HTTP 403。透過一般網頁瀏覽器存取時,這些 URL 皆有效。
-
GitHub — openai/codex — 開放原始碼儲存庫、版本發布與討論。 ↩↩↩
-
Codex CLI Windows 支援 — Windows 安裝與 WSL 指引。 ↩
-
Codex IDE Extension — VS Code、Cursor 與 Windsurf 整合。 ↩
-
Codex Cloud — Cloud 任務文件與網際網路存取控制。 ↩↩
-
Codex Security — Sandbox 架構與安全模型。 ↩↩↩
-
macOS Seatbelt Sandbox — Apple sandbox-exec framework 的社群文件(Apple 尚未發布官方開發者文件)。注意:此 wiki 可能會封鎖自動化存取(HTTP 403);另請參閱 macOS 上的
man sandbox-exec。 ↩↩↩ -
Linux Landlock LSM — Kernel 檔案系統存取控制。 ↩
-
Breaking Out of the Sandbox — 社群 Sandbox 設定模式。 ↩
-
AGENTS.md Open Standard — Linux Foundation 旗下的跨工具指令標準。 ↩
-
使用 AGENTS.md 的自訂指令 — 官方指南。 ↩
-
Codex MCP 整合 — MCP server 設定與管理。 ↩
-
使用 Agents SDK 建立工作流程 — 將 Codex 作為 MCP server,用於多代理協調。 ↩
-
Agent Skills — Skills 系統文件。 ↩
-
Codex CLI 功能 — Plan mode、steer mode 與協作功能。 ↩↩
-
Non-Interactive Mode —
codex exec文件。 ↩ -
Introducing the Codex App — Desktop app 發布公告。 ↩↩↩
-
Codex App Documentation — Desktop app 功能與疑難排解。 ↩
-
Codex GitHub Action — CI/CD 整合。 ↩
-
Codex Pricing — 訂閱與 API 定價。 ↩
-
Codex Configuration Reference — 企業 requirements.toml schema 與 MDM 發布。 ↩↩↩
-
Best Practices for Using Codex — 社群論壇討論串。 ↩
-
feiskyer/codex-settings — 社群維護的設定、skills 與 prompts。 ↩
-
Codex CLI Releases — GitHub 版本說明。 ↩↩
-
Introducing GPT-5.3-Codex-Spark — Cerebras 夥伴關係,1000+ tok/s。 ↩↩
-
Introducing GPT-5.3-Codex — 統一模型發布。 ↩
-
Introducing GPT-5.2-Codex — Context compaction 與大規模變更。 ↩
-
Building More with GPT-5.1-Codex-Max — 多視窗壓縮。 ↩
-
Codex is Now Generally Available — DevDay 2025 公告。 ↩
-
Introducing Upgrades to Codex — GPT-5-Codex + IDE extension。 ↩↩
-
Codex CLI is Going Native — Rust 重寫討論。 ↩
-
Codex Updates: Internet Access and Plus Rollout — 2025年6月擴展。 ↩
-
Introducing Codex — Cloud agent 發布。 ↩↩
-
Deprecating chat/completions support in Codex — OpenAI 宣布移除 Codex 的 chat/completions API,已於 2026年2月完成。 ↩
-
Codex CLI v0.101.0 — 模型解析改進、記憶細節優化、穩定性。2026年2月12日。 ↩↩
-
Codex CLI v0.100.0 — 實驗性 JS REPL、多重速率限制、WebSocket transport、記憶命令、強化 Sandbox。2026年2月12日。 ↩
-
Codex CLI v0.99.0 — 並行 shell 命令、
/statusline、可排序的 resume picker、GIF/WebP 支援、shell 快照。2026年2月11日。 ↩↩ -
Codex CLI v0.98.0 — GPT-5.3-Codex 支援、steer mode 穩定並設為預設、模型切換修正。2026年2月6日。 ↩
-
Codex CLI v0.97.0 — 「Allow and remember」MCP approvals、即時 skill 偵測、
/config診斷、記憶管線。2026年2月6日。 ↩ -
Codex CLI v0.96.0 — Async thread/compact v2、WebSocket 速率限制、unified_exec 非 Windows、設定來源。2026年2月6日。 ↩
-
Codex CLI v0.95.0 —
codex app命令、個人 skills、平行 shell tools、git 強化。2026年2月6日。 ↩ -
Codex CLI v0.94.0 — Plan mode 預設、personality 穩定、來自
.agents/skills的 skills、執行階段指標。2026年1月30日。 ↩ -
Codex CLI v0.93.0 — SOCKS5 proxy、plan mode streaming、
/apps、smart approvals 預設、SQLite logs。2026年1月29日。 ↩ -
Codex CLI v0.92.0 — API v2 threads、thread 篩選、MCP OAuth scopes、多代理協作。2026年1月29日。 ↩
-
Codex CLI v0.91.0 — 將 sub-agents 上限從 12 降至 6,以收緊資源護欄。2026年1月25日。 ↩
-
Codex CLI v0.88.0 — Device-code auth fallback、協作模式、
/fork、remote models、model_personality設定。2026年1月21日。 ↩ -
Codex CLI v0.102.0 — 統一權限流程、結構化網路 approvals、可自訂多代理角色、模型重新路由通知。2026年2月17日。 ↩↩
-
Codex CLI v0.103.0 — 透過 prepare-commit-msg hook 標註 commit co-author、較豐富的 app listing metadata/branding、移除
remote_modelsfeature flag。2026年2月17日。 ↩ -
Codex CLI v0.104.0 — WS_PROXY/WSS_PROXY WebSocket proxy 支援、命令使用不同 approval IDs、thread archive/unarchive 通知。2026年2月18日。 ↩↩↩
-
Codex Changelog — Codex App v26.217:拖放重新排序、模型降級警告、模糊檔案搜尋改進。Codex Config Reference — 完整設定鍵參考。2026年2月。 ↩↩
-
Codex Pricing — 方案級距、每 5 小時視窗的用量限制、credit 成本,以及 Free/Go 促銷存取。2026年2月。 ↩
-
Codex CLI v0.78.0 —
Ctrl+G外部編輯器、專案感知設定分層、macOS MDM 設定、TUI2 transcript nav、.dmginstallers。2026年1月6日。 ↩ -
Codex CLI v0.66.0 — Exec policy system、Windows 上的 CRLF 保留、cloud exec
--branch、Linux Sigstore signing。2025年12月9日。 ↩ -
Codex CLI v0.59.0 — Native compaction、tool output limit 提高至 10K tokens、Windows Agent mode sandbox、
/status中的 credits。2025年11月19日。 ↩ -
Codex CLI v0.50.0 —
/feedback診斷、sandbox violation 風險評估、MCP 啟動改進、env var 遮蔽。2025年10月25日。 ↩↩ -
Codex CLI v0.45.0 — 破壞性變更:
codex login --api-key→--with-api-key(stdin)。OAuth MCP驗證、平行工具呼叫。2025年10月6日。 ↩ -
Codex CLI v0.40.0 — 預設模型→
gpt-5-codex、220K tokens時自動壓縮、/review命令、git復原、Windows二進位檔。2025年9月23日。 ↩ -
Codex CLI v0.2.0 — 首個Rust二進位檔版本。提供macOS(aarch64/x86_64)與Linux(gnu/musl)的預建二進位檔、
codex-exec與codex-linux-sandbox工具。2025年6月30日。 ↩ -
GitHub — openai/codex LICENSE — Apache License 2.0。原始開源發布時間為2025年4月。 ↩↩↩
-
Codex CLI v0.106.0 — 直接安裝指令碼、js_repl升級至/experimental(Node 22.22.0+)、Default模式中的request_user_input、以diff為基礎的記憶遺忘、zsh-fork sandbox繞過修正、約1M字元輸入上限、Ctrl-C sub-agent修正。2026年2月26日。 ↩↩↩↩↩↩↩↩↩↩
-
Codex CLI v0.105.0 — TUI語法醒目提示搭配/theme、語音轉錄、spawn_agents_on_csv、/copy /clear Ctrl-L、彈性approval控制、Linux /dev檔案系統、js_repl錯誤復原。2026年2月25日。 ↩↩↩↩↩↩↩↩↩
-
Codex CLI v0.107.0 — 將執行緒fork至sub-agents、即時語音裝置選擇、自訂工具多模態輸出、可透過
codex debug clear-memories設定的memories。2026年3月2日。 ↩↩↩↩↩↩ -
Codex Changelog — App v26.226 — composer中的MCP捷徑、review comments中的@mentions、Mermaid圖表錯誤處理。2026年2月26日。 ↩↩↩
-
Introducing GPT-5.4 — 旗艦frontier模型,結合GPT-5.3-Codex程式撰寫能力、更強推理、原生電腦使用能力,以及1M context windows。2026年3月5日。 ↩↩↩↩↩
-
Codex CLI v0.110.0–v0.111.0 — 用於skills/MCP/app connectors的plugin系統(v0.110.0)、fast mode預設啟用、js_repl動態imports、工作階段開始時探索plugin(v0.111.0)。2026年3月5日。 ↩↩↩↩↩
-
Codex App for Windows — 原生Windows app,支援PowerShell、原生sandbox、skills/automations/worktrees。App v26.304(2026年3月4日)、v26.303(2026年3月3日)。 ↩↩↩↩↩↩
-
Introducing GPT-5.2-Codex — GPT-5.3-Codex-Spark:純文字研究預覽模型,針對近乎即時的coding iteration最佳化。透過Cerebras合作提供給ChatGPT Pro使用者。128K context。 ↩↩↩
-
Codex CLI v0.112.0 — @plugin mentions搭配自動納入的context、TUI模型選擇介面、per-turn sandbox policy中的可執行權限profiles、JS REPL狀態修正、SIGTERM處理、Linux bubblewrap user namespace、macOS sandbox改進。2026年3月8日。 ↩↩↩
-
Codex CLI v0.113.0 — 內建request_permissions工具、plugin marketplace擴充(metadata、auth checks、uninstall)、app-server streaming搭配TTY/PTY、permission-profile設定語言、image generation儲存至CWD、web search工具設定、強化的network proxy policy。2026年3月10日。 ↩↩↩↩
-
Codex CLI v0.114.0 — 實驗性code mode、實驗性hooks引擎(SessionStart、Stop事件)、WebSocket健康檢查端點、停用system skills設定、handoff transcript context、強化的$ mention選擇器。2026年3月11日。 ↩↩↩↩
-
OpenAI Developer Changelog — March 11, 2026 — GPT-5.1 models已從ChatGPT移除;既有對話會自動在GPT-5.3 Instant、GPT-5.4 Thinking或GPT-5.4 Pro上延續。 ↩↩
-
Codex Changelog — App v26.312 — 可自訂themes,包含色彩控制與字型選擇;改版Automations介面,支援local/worktree執行與自訂reasoning levels;效能改進。2026年3月12日。 ↩↩↩↩
-
Codex CLI v0.115.0 — 透過
view_image與codex.emitImage進行完整解析度影像檢查、js_repl公開codex.cwd/codex.homeDir、即時WebSocket轉錄模式、app-server v2檔案系統RPCs、搭配guardian subagent的Smart Approvals、Responses API tool-search。修正:subagent sandbox繼承、js_repl U+2028/U+2029停滯、TUI退出卡住、profile settings保留、MCP/elicitation改進。2026年3月16日。 ↩↩↩ -
Codex CLI v0.116.0 —
UserPromptSubmithook event、app-server TUI中的ChatGPT device-code auth、透過suggestion allowlist與remote sync讓plugin安裝更順暢、realtime sessions搭配近期thread context、降低音訊自我中斷。修正:WebSocket prewarm首次回合停滯、remote resume/fork的conversation history、symlinked checkouts/AppArmor上的Linux sandbox、agent job finalization競態。合併77個PRs。2026年3月19日。 ↩↩ -
Codex CLI v0.117.0 — 一級plugins(product-scoped sync、
/plugins瀏覽器、install/remove)、sub-agents v2(path-based addresses、structured messaging、agent listing)、/titleterminal-title選擇器、app-server TUI預設啟用並支援!shell命令/filesystem watch/remote WebSocket bearer auth/prompt history recall、image workflows(view_imageURLs、可重新開啟的生成影像、resume後仍保留的history)、移除legacy artifact/read_file/grep_files工具、改善舊版distros上的Linux sandbox、Windows restricted-token sandbox改進。2026年3月28日。 ↩↩↩↩↩↩↩↩↩↩↩↩↩ -
Introducing GPT-5.4 mini and nano — GPT-5.4 mini:400K context、每MTok $0.75/$4.50、GPT-5.4 quota的30%、快2倍。可於Codex app、CLI、IDE extension與web使用。2026年3月17日。 ↩↩↩↩↩
-
Codex Security: now in research preview — 具備context-aware能力的應用程式安全review。透過Codex web提供給Pro/Enterprise/Business/Edu。已掃描1.2M commits,發現10,561項high-severity findings,指派14個CVEs。2026年3月6日。 ↩↩↩↩↩
-
Codex CLI v0.118.0 — Windows proxy-only sandbox networking、ChatGPT device-code auth、
codex execprompt-plus-stdin、dynamic bearer tokens、.codex檔案保護、Linux bwrap修正、TUI app-server regressions、MCP啟動穩定性、Windows apply_patch修正。2026年3月31日。 ↩↩ -
Codex now offers pay-as-you-go pricing for teams。OpenAI,2026年4月2日。Business年繳定價降至每席每月$20。Codex-only seats開放給Business與Enterprise,採token-based billing、無固定席位費、無rate limits。 ↩
-
Codex CLI v0.119.0。「v0.119.0:Realtime voice V2(WebRTC、可設定transport、voice selection、原生TUI media)、MCP Apps(resource reads、tool-call metadata、elicitations、file uploads)、remote workflows(egress websocket、
--cdforwarding、codex exec-server)、Ctrl+O複製回應、依ID/name使用/resume、Warp OSC 9 notifications。」2026年4月10日。 ↩ -
Codex CLI v0.120.0。「v0.120.0:Realtime V2串流background agent進度、hook activity UI改進、SessionStart hooks可區分
/clear、code mode中的MCPoutputSchema、Windows sandbox symlink handling、tool search排序修正。」2026年4月11日。 ↩ -
Codex CLI v0.121.0。2026年4月15日。Plugin Marketplace(
codex marketplace add支援GitHub、git URL、本機目錄、marketplace.jsonURL)+ app-server對應功能(#17087、#17717、#17756)。TUI反向歷史搜尋Ctrl+R,並可叫回slash-command(#17550、#17336)。TUI記憶選單新增重設按鈕與逐筆記憶刪除(#17632、#17626、#17913、#17937、#17844)。第2階段記憶整合模型升級至GPT-5.4(#17384)。記憶重設會保留過往rollouts(#17919)。使用Bubblewrap的安全devcontainer設定檔(僅WSL2;拒絕WSL1)(#10431、#17547、#17559)。macOS sandbox:Unix socket允許清單(#17654)、解除私有DNS封鎖(#17370)。移除danger-full-access僅denylist模式(#17732)。MCP Apps工具呼叫支援(#17364)、MCP工具namespace(#17404)、supports_parallel_tool_calls旗標管線(#17667)、透過MCP工具metadata提供sandbox狀態metadata(#17763、#17957)、扁平化延遲工具呼叫(#17556)。Guardian review會停用hooks(#17872)。狀態列新增context百分比指示器(#17637、#17420)。CLI更新公告(#17942)。codex-thread-store介面(#17659、#17824)。Windowsresume --last逐字路徑修正(#17414)。總計180+個commits。完整PR清單另請參閱rust-v0.120.0...rust-v0.121.0compare URL。 ↩↩↩↩↩↩↩↩↩↩↩↩ -
Introducing GPT-5.5。OpenAI公告,2026年4月23日。Context window:Codex中為400K,API中為1M(分別依OpenAI的GPT-5.5-in-Codex可用性頁面與GPT-5.5 API模型文件)。價格(API):每MTok輸入$5 / 輸出$30(為GPT-5.4費率的2倍;OpenAI表示在token效率改善後,實際增幅約20%)。Benchmark:Terminal-Bench 2.0為82.7%(目前公開可用模型中的SOTA)、GDPval為84.9%(44種職業)、OSWorld-Verified為78.7%(真實電腦操作)、Tau2-bench Telecom為98.0%(未進行prompt tuning)。2026年4月23日起,在Codex CLI/web/desktop提供給ChatGPT Plus/Pro/Business/Enterprise/Edu/Go;2026年4月24日起在OpenAI API提供。OpenAI給出的指引:「GPT-5.5 is now available in Codex as OpenAI’s newest frontier model for complex coding, computer use, knowledge work, and research workflows, and is the recommended choice for most Codex tasks.」另請參閱:Introducing upgrades to Codex(2026年4月17日 — 背景電腦使用、90+個新plugin合作夥伴,包含Atlassian Rovo、CircleCI、CodeRabbit、GitLab Issues、Microsoft Suite、Neon by Databricks、Remotion、Render與Superpowers);NVIDIA blog: GPT-5.5 Powers Codex on NVIDIA Infrastructure;TechCrunch: OpenAI releases GPT-5.5。 ↩↩↩↩↩↩↩
-
Codex CLI v0.122.0與v0.123.0。v0.122.0:檔案系統deny-read glob政策 + 受管理deny-read需求 + 平台sandbox強制執行 + 隔離的
codex exec執行,會忽略使用者設定或規則;預設啟用工具探索與影像生成;MCP與js_repl支援更高細節的影像處理與原始細節metadata;app-server跨用戶端解決過期prompt;續接/分叉threads會立即重播token用量;remote-control啟動可容忍缺少ChatGPT auth;MCP啟動取消可再次透過app-server sessions運作;內部分拆為codex-core-plugins並重組connector。v0.123.0(2026年4月23日):內建amazon-bedrock模型provider,支援可設定AWS profile;/mcp verbose提供完整MCP伺服器診斷、resources與resource templates,同時讓一般/mcp維持快速;plugin MCP載入可接受.mcp.json中的mcpServers與頂層伺服器對應表;即時handoffs會將transcript deltas傳給背景agents,並允許明確silent-stay;遠端環境支援特定host的remote_sandbox_config需求;更新隨附模型metadata。修正:rollback後/copy會複製最新可見assistant回應(不是rollback前內容)、手動shell命令執行時提交的後續文字會排入佇列(不再卡在Working狀態)、VS Code WSL終端機中的Unicode/dead-key輸入(在該處停用增強鍵盤模式)、不再從shell snapshots還原過期proxy環境變數、codex exec會繼承根層級共享旗標,例如sandbox與模型選項、從TUI transcripts移除外洩的review prompts。 ↩↩↩ -
Codex CLI v0.124.0與v0.125.0。v0.124.0(2026年4月23日):TUI快速reasoning控制(
Alt+,降低、Alt+.提高),模型升級時會將reasoning重設為新模型預設值;app-server sessions可管理多個環境,並在遠端設定中支援每回合選擇環境+工作目錄;對OpenAI相容provider提供一等Amazon Bedrock支援(AWS SigV4簽署、AWS憑證auth);遠端plugin marketplaces支援可靠的詳細資料查詢與更大的結果頁;hooks現已穩定 — 可在config.toml與requirements.toml中以inline方式設定,觀察MCP工具以及apply_patch與長時間執行的Bash sessions;符合資格的ChatGPT方案預設使用Fast service tier,除非明確選擇退出。修正:Cloudflare cookies會在核准的ChatGPT hosts之間保留(降低auth失敗)、負載下的websocket事件清空與更乾淨的關閉、permission-mode漂移可跨side conversations保留、mailbox工作排入佇列時wait_agent會即時返回、未明確使用cwd的相對命令可讓本機stdio MCP啟動採用正確路徑解析、啟動時managed-config邊界案例(未知feature需求改為警告而非中止、cloud-requirement錯誤更清楚)。v0.125.0(2026年4月24日):app-server integrations支援Unix socket transport、利於分頁的resume/fork、sticky environments、遠端thread config/store管線;app-server plugin管理可安裝遠端plugins並升級已設定的marketplaces;permission profiles可在TUI sessions、使用者turns、MCP sandbox狀態、shell升級與app-server APIs之間來回保留;model providers擁有模型探索,並向app clients公開AWS/Bedrock帳戶狀態;codex exec --json會為程式化消費者回報reasoning-token用量;rollout tracing會記錄工具、code-mode、session與multi-agent關係,並提供debug reducer命令。修正:/review中斷不再卡住TUI、改善exec-server輸出處理與stream關閉、app-server會尊重明確不受信任的專案設定、notification bursts期間的websocket client中斷問題、Windows sandbox啟動與背景程序處理、針對thread限制、agent paths與MIME types強化config-schema驗證。 ↩↩↩ -
Codex CLI v0.128.0。2026年4月30日發布。新增持久化
/goalworkflows、codex update、可設定的TUI keymaps、擴充permission profiles、plugin marketplace改善、外部agent session匯入,以及MultiAgentV2設定更新;修正resume/interruption、TUI、network、Windows sandbox、Bedrock、MCP與plugin邊界案例;棄用--full-auto;移除js_repl。 ↩↩↩↩↩↩ -
OpenAI Codex configuration reference與Codex sandbox configure defaults。存取日期:2026年5月11日。記載
approval_policy、sandbox_mode、default_permissions、[permissions.<name>.filesystem]、[permissions.<name>.network]、內建permission profiles,以及on-failure棄用事項。 ↩↩↩↩↩↩ -
OpenAI API deprecations: 2026-04-22 legacy GPT model snapshots。存取日期:2026年5月5日。列出2026年7月23日關閉的舊版Codex相關模型snapshots,包含
gpt-5.2-codex與gpt-5.1-codex-mini,替代項為gpt-5.4與gpt-5.4-mini。 ↩↩↩ -
Codex CLI v0.129.0。於2026年5月7日17:02 UTC發布。新增 composer 中的模態 Vim 編輯(
/vim命令、可設定的預設模式)、重新設計的 TUI 工作流程選擇器(更容易 resume/fork、原始 scrollback 模式)、可在 TUI 內探索並切換生命週期 hooks 的/hooks瀏覽器、支援主題的狀態列並可選擇顯示 PR 與分支變更摘要、plugin 管理升級(workspace sharing、share 存取控制、來源篩選、從/plugins執行 marketplace 操作)、/goal生命週期變更(實驗性 goals 在 resume 後維持暫停,除非重新選擇啟用——此變更調整先前 v0.128.0 的預設行為)、Linux sandbox 啟動強化、Windows sandbox 可靠性改善,以及 vendored Bubblewrap 升級至0.11.2,納入上游安全修補。另請參閱:Codex Changelog與Codex CLI page——後者記錄了2026年5月 usage limit boost(Codex Plus 5小時限制提高25倍,以及每月100美元級距加倍,兩者皆至2026年5月31日止)。 ↩↩↩↩↩↩↩↩↩↩↩ -
Codex for Chrome與Codex Changelog 的2026年5月7日項目。依公告所述:「透過新的 Chrome extension,Codex 更擅長在瀏覽器中與 app 和網站協作。它會在背景跨分頁平行運作,不會接管您的瀏覽器;而且您仍可控制 Codex 能使用哪些網站。」 ↩↩↩↩↩
-
Codex CLI v0.130.0。於2026年5月8日23:09 UTC發布。新功能:
codex remote-control頂層命令,可作為 headless app-server entrypoint(#21424);plugin 詳細資料會顯示 bundled hooks,plugin sharing 顯示連結 metadata、discoverability 控制與 share settings 更新(#21447、#21495、#21637);app-server thread pagination,並支援 unloaded / summary / full turn item views(#21566);透過 AWSaws loginconsole-login credentials 進行 Bedrock auth(#21623);view_image會在多環境 session 中透過所選環境解析(#21143)。Bug 修正:即時 app-server threads 不需重新啟動即可套用 config 變更(#21187);turn diffs 在apply_patch操作期間保持準確,包括部分失敗情境(#21180、#21518);透過ThreadStore處理 thread summaries / renames / resume / fork,包括 pathless threads(#21264、#21265、#21266);remote compaction 會為 v2 streams 發出response.processed,且在 API-key compact requests 中省略service_tier(#21642、#21676);Windows sandbox setup 會授予 sandbox users 存取 desktop runtime binary cache 的權限(#21564);codex exec啟動 banner 不再印出「research preview」字樣(#21683)。雜項維護:可設定的 OpenTelemetry trace metadata,以及更豐富的 review/feedback analytics(#21556、#18747、#21434、#21498);Cargo profiling build profile、Dependabot cooldown、cargo-shear升級、完全限定的 GitHub Action pins(#21436、#21547、#21574、#21584、#21599);移除未使用的 device-key APIs、額外 skills roots、remote thread-store impl、以字串為 key 的 MCP tool maps(#21487、#21485、#21596、#21454)。比較 URL:rust-v0.129.0...rust-v0.130.0。另請參閱:Codex Changelog。 ↩↩↩↩↩↩↩↩↩↩↩↩↩ -
Codex Changelog。2026年5月5日至9日的歷史脈絡:GPT-5.5 Instant 推出至 free tier,而 v0.131.0 alpha 線在後續5月18日 stable v0.131.0 發布之前已開始;後者記錄於96。 ↩↩
-
Build plugins — Add a marketplace from the CLI。存取日期:2026年5月11日。記錄
codex plugin marketplace add、可接受的 marketplace source types、--ref、--sparse,以及 marketplace upgrade/remove 命令。 ↩ -
Codex CLI v0.131.0-alpha.9。於2026年5月12日發布。這是歷史 prerelease alpha 線;就本指南目前目標而言,已由96中的5月18日 stable v0.131.0 release 取代。 ↩↩
-
作者於2026年5月15日執行的已清理本機 Codex-harness hygiene audit。該次檢查區分了 executable source、public/private docs、generated caches、session records、shell snapshots、logs 與 intentional secret stores;在適當情況下將 helper credentials 轉為需要環境變數的 configuration;對高信心 secret shapes 的 model-visible history 進行遮蔽;並記錄剩餘的 prevention-hook 與 forensic-history 缺口。確切路徑、token 值、detector patterns 與私有 workflow internals 均刻意省略。 ↩↩↩
-
Codex Changelog。2026年5月18日 Codex CLI 0.131.0 項目。新功能包括更豐富的 TUI session controls 與 status display、跨 files/directories/plugins/skills 的統一
@mention search、marketplace CLI commands、version-aware plugin sharing、預設啟用的 plugin hooks、由 daemon 管理的codex remote-control、registry-backed remote environments、openai-codexPython SDK updates,以及codex doctordiagnostics。Bug 修正涵蓋 TUI rendering/interaction、Windows sandbox behavior、managed read restrictions、app-server/local-state startup safety、Git/auth reliability,以及 remote cleanup。2026年5月19日的 current-session verification:codex --version回傳codex-cli 0.131.0,且npm view @openai/codex version dist-tags.latest time.modified --json回傳 latest0.131.0,time.modified為2026-05-18T22:00:51.726Z。 ↩↩↩↩↩ -
Codex CLI v0.132.0。於2026年5月20日發布。新增一級支援的 Python SDK authentication(API key、ChatGPT browser/device-code flows、account inspection、logout)、更簡潔的 text-only turn APIs 並搭配更豐富的
TurnResult、codex exec resume --output-schema、透過批次 terminal probes 加速 TUI startup、standard-Codex-auth remote executor registration,以及 app-server image-fidelity preservation。修正項目包括 usage limits 與重複 blockers 的 goal continuation stop conditions、resume picker trust/paste behavior、MCP replay/elicitation routing、remote websocket keepalive、repo-relative diff paths、Windows doctor npm detection,以及 static MSVC runtime linking。 ↩↩↩↩↩ -
Codex CLI v0.133.0。於2026年5月21日發布。Goals 預設啟用,並提供專用 storage 與 active-turn progress tracking;
codex remote-control新增 foreground readiness/status,以及 daemon-stylestart/stop;permission profiles 新增 list APIs、inheritance、managedrequirements.toml支援、runtime refresh,以及更強的 Windows sandbox integration;plugin discovery 新增 marketplace-aware list output、installed versions、marketplace roots 與 remote collection support;extensions 可觀察 subagent start/stop、tool execution、turn metadata,以及 async approval/turn processing。2026年5月21日的 current-session verification:codex --version回傳codex-cli 0.131.0,而npm view @openai/codex version dist-tags.latest time.modified --json回傳 latest0.133.0,time.modified為2026-05-21T17:13:06.823Z。 ↩↩↩↩↩↩↩ -
OpenAI ChatGPT release notes與ChatGPT Enterprise & Edu release notes。2026年5月21日 Codex 項目:Appshots、Goal mode GA、in-app browser annotations、locked Computer Use、browser-use improvements、Enterprise/Edu analytics,以及 plugin-sharing availability notes。另請參閱 Appshots、In-app browser與Computer Use文件,存取日期:2026年5月25日。 ↩↩↩↩↩↩↩↩
-
OpenAI Codex prompting docs — Goal mode。存取日期:2026年5月25日。將 Goal mode 記錄為持續性 objective,並在 Codex app、IDE extension 與 CLI 中提供
/goalentry points;若 slash command 未出現,也提供features.goals/codex features enable goalsfallback guidance。 ↩↩↩ -
OpenAI Codex GitHub releases。存取日期:2026年5月26日。releases page 將
0.134.0-alpha.1、0.134.0-alpha.2與0.134.0-alpha.3列為 prereleases,並標示0.133.0為 latest stable。2026年5月26日的 current-session verification:本機codex --version回傳codex-cli 0.133.0;npm view @openai/codex version dist-tags.latest time.modified --json回傳version0.133.0、dist-tags.latest0.133.0,以及time.modified2026-05-23T01:26:52.705Z。 ↩↩↩ -
Codex CLI v0.140.0版本資訊和Codex Changelog (OpenAI Developers)。已於2026年6月15日升級為穩定版(來自v0.140.0-alpha系列)。新功能:
/usage檢視每日、每週與累計帳戶 token 活動;/goal會在遠端 app-server 工作階段中保留超大文字、大型貼上區塊與圖片附件;可透過codex delete、/delete和 app-serverthread/delete刪除工作階段,並具備確認防護;/import可從Claude Code選擇性匯入設定、專案設定與近期聊天;輸入@預設會開啟統一提及選單,涵蓋檔案、plugins與skills;受管理的 Amazon Bedrock API金鑰驗證,以及CLI和MCP OAuth憑證的加密本機儲存。錯誤修正:損毀的 SQLite 狀態資料庫會自動備份,並從 rollout 資料重建;在有排隊指引時按下 Esc,/review不再當機;透過暫時性啟動失敗重試與停用伺服器保留,提升MCP可靠性;修正遠端 plugin 解除安裝要求,並顯示需要驗證的 apps;保留「Don’t remind me」更新略過狀態,並清除過期的執行中 hook 指示;非 TTY 背景命令可用 Ctrl-C 中斷,同時保留輸出。效能/維護:保留 Git 檔案系統監控,並加速大型 repo 的封存查找;從 TUI 移除實驗性/realtime語音控制與音訊相依套件。截至2026年6月16日,最新預先發布版本是rust-v0.141.0-alpha系列(prerelease)——0.141.0仍為 alpha,且本指南追蹤穩定版,因此不涵蓋該版本。本次工作階段於2026年6月16日驗證:GitHub releases 與 OpenAI Codex changelog 確認rust-v0.140.0為最新穩定版。 ↩↩↩↩↩↩↩ -
Codex CLI v0.141.0版本資訊和Codex Changelog (OpenAI Developers)。已於2026年6月18日升級為穩定版(來自v0.141.0-alpha系列)。安全性/基礎架構:遠端執行器使用已驗證、端對端加密的 Noise-relay 通道;TLS 支援 P-521 憑證簽章,以相容企業 proxy。跨平台:遠端執行會保留執行器原生工作目錄與 shell;Windows sandbox 執行改進,包括自動憑證復原。效能:透過快取 tool search,降低大型、tool 密集工作階段的延遲與記憶體用量;prompt-image 快取上限為64 MiB。UI:TUI 輸入提示可在閒置後透過倒數計時自動解析;realtime clients 取得 speech-append 控制。截至2026年6月19日,最新預先發布版本是
rust-v0.142.0-alpha系列(prerelease)——0.142.0仍為 alpha,且本指南追蹤穩定版,因此不涵蓋該版本。本次工作階段於2026年6月18日驗證:GitHub releases 與 OpenAI Codex changelog 確認rust-v0.141.0為最新穩定版。 ↩↩ -
Codex CLI v0.142.0版本資訊和Codex Changelog (OpenAI Developers)。已於2026年6月22日升級為穩定版(來自v0.142.0-alpha系列)。新功能:
/usage可顯示並兌換已取得的使用量限制重設點數,並具備確認、重試與重新整理的可用狀態;/plugins將遠端 plugins 整理為 OpenAI Curated、Workspace 與 Shared with me 區段,符合條件的回合也可推薦並安裝相關 plugins;可設定的 rollout token 預算會跨 agent threads 追蹤使用量、提供剩餘預算提醒,並在用盡時中止回合;app-server clients 可在 thread 與 turn 層級,將 multi-agent delegation 設定為停用、僅明確要求,或主動執行;indexed web-search 模式允許即時搜尋,同時將直接頁面存取限制在伺服器核准的 URL;Codex 可接收排程的 UTC 時間提醒,並直接查詢目前時間,包括透過 client 提供的 app-server clocks。錯誤修正:Linux TUI 在 Ctrl+Z 暫停/fg 繼續後的顯示;exec-server process 與 stdio MCP工作階段重新連線韌性;跨作業系統保留遠端環境路徑;plugin 載入、安裝與 manifest 處理改進;parent-agent 可看見 subagent 錯誤;thread/list與thread/search中的 goal-first thread 持久化。截至2026年6月23日,最新預先發布版本是rust-v0.143.0-alpha系列(prerelease)——0.143.0仍為 alpha,且本指南追蹤穩定版,因此不涵蓋該版本。本次工作階段於2026年6月23日驗證:GitHub releases 與 OpenAI Codex changelog 確認rust-v0.142.0為最新穩定版。 ↩↩↩ -
Codex CLI v0.139.0版本資訊和Codex Changelog (OpenAI Developers)。已於2026年6月9日(20:13 UTC)升級為穩定版;在GitHub上標示為 Latest;安裝方式為
npm install -g @openai/[email protected]。新功能:code mode 可直接呼叫獨立 web search(也包括從巢狀JavaScript tool calls 中呼叫),並接收純文字結果;tool/connector 輸入 schemas 保留oneOf/allOf結構,以便更好保留大型 schema 結構並提升MCP相容性;codex doctor新增 editor 與 pager 環境詳細資料,並在JSON中遮蔽敏感值;plugin marketplace 自動化會在codex plugin marketplace list --json中公開 sources,並加快快取 catalog 的 plugin 列表速度。錯誤修正:codex resume --last/codex fork --last會將尾端 args 視為 prompts,而非 session IDs;subagent MCP啟動警告不再出現在錯誤的 thread context;圖片編輯會參照精確檔案路徑;tilde URL 會在 TUI 中完整轉為連結;thread resets(/new、/clear、/fork)會保留雲端管理的 requirements/feature flags;sandbox 執行會一致保留 approval decisions,並強制僅限 proxy 的網路。維護:分離含 line tables 的 symbol archives;rusty_v8升級至149.2.0。截至2026年6月9日,最新預先發布版本是rust-v0.140.0-alpha系列(prerelease)——0.140.0仍為 alpha,且本指南追蹤穩定版,因此不涵蓋該版本。本次工作階段於2026年6月9日驗證:GitHub releases 與 OpenAI Codex changelog 確認rust-v0.139.0為最新穩定版。 ↩↩↩ -
Codex CLI v0.138.0版本資訊和Codex Changelog (OpenAI Developers)。已於2026年6月8日(23:00 UTC)升級為穩定版;
prerelease: false,在GitHub上標示為 Latest;安裝方式為npm install -g @openai/[email protected]。新增 macOS 與 Windows 上的/app桌面交接、向 models 暴露本機圖片路徑、更彈性的 reasoning-effort 選擇,以及用於 plugin 自動化的結構化JSON輸出。已於2026年6月9日由rust-v0.139.0取代為最新穩定版。 ↩↩ -
Codex CLI v0.137.0版本資訊和Codex Changelog (OpenAI Developers)。已於2026年6月4日(01:17 UTC)從v0.137.0-alpha系列升級為穩定版。TUI:F13–F24 keybindings、可搜尋選單中的貼上、精簡的 reasoning-only status/title item。Enterprise:admin flows 中的每月 credit limits,以及雲端管理的 config bundles。遠端控制:client 啟動 pairing 與 controller-grant 管理。Plugins:plugin workflows 的機器可讀JSON輸出,以及快取遠端 catalog suggestions。在更多 code-mode flows 中提供託管 web/image tools,並平行執行獨立 web searches;multi-agent v2 runtime 改進(更清晰的 follow-up、metadata defaults)。修正:prompt cancellation 會復原 draft/attachments/collaboration mode、macOS app launch 與 Windows SQLite startup reliability、plugin manifest ordering/dedup、permission requests 會遵循 environment identity。本次工作階段於2026年6月4日(PST)驗證:GitHub releases 顯示
rust-v0.137.0為最新穩定版。 ↩↩ -
Codex CLI v0.136.0發行說明與Codex Changelog(OpenAI Developers)。在
v0.136.0-alpha.2(5月31日)之後,於2026年6月1日(17:49 UTC)升級為 stable。新增工作階段封存(TUI中的/archive;codex archive/codex unarchiveCLI命令;已封存工作階段在還原前不得 resume/fork);OSC 8中繼資料,讓 TUI markdown 網頁連結維持可點擊,並在狹窄表格中以 key/value fallback 顯示;codex app-server --stdiostdio 模式啟動,加上 initial-turns-page thread resume 與更豐富的 MCP伺服器狀態;CODEX_API_KEY用於在已核准的 OpenAI 主機上遠端執行;遠端控制 websockets 的短效伺服器 token;codex sandbox setup --elevatedWindows 管理員佈建(alpha);以及透過原生 image-artifact completion pipeline 提供、以功能旗標控管的獨立影像生成擴充。錯誤修正:ChatGPT auth 接近到期 token 重新整理,並在重用 refresh token 時重新登入;阻止/diff執行儲存庫提供的 Git helpers;中斷後清理 sandboxed-command,並強制套用 deny-read 規則;從 transcripts 為 resumed-TUI prompt-history 建立初始內容;vim normal-mode 編輯;以及 Bedrock auth fallback 至AWS_REGION/AWS_DEFAULT_REGION。2026年6月2日(PST)目前工作階段驗證:GitHub releases 頁面顯示rust-v0.136.0為最新 stable(非 prerelease)tag。 ↩↩↩↩↩ -
Codex Changelog(OpenAI Developers)與openai/codex releases。Codex CLI 0.134.0(2026年5月26日)新增本機對話記錄搜尋,支援不區分大小寫的內容比對;讓
--profile成為 CLI/TUI/sandbox 流程中的主要 profile 選擇器,並提供 legacy-config 遷移指引;改善 MCP設定,支援依伺服器指定環境,加上用於 streamable HTTP servers 的 OAuth;透過保留本機$ref/$defs並在公開前壓縮過大的 schemas,使 connector tool schemas 更可靠;允許並行執行標示readOnlyHint的唯讀 MCP tools;並加入更豐富的 extension/hook context(extension tools 的對話記錄,以及跨 auto-review runtime sync 持續保留的 permission-profile metadata)。Codex CLI 0.135.0(2026年5月28日)新增更完整的codex doctor診斷,涵蓋環境、Git、terminal、app-server 與 thread inventory;當 TUI 透過 remote 連線時,在/status顯示 remote connection details 與 server version;新增 vim mode text-object 編輯,改善 word/line-end 行為並提供可設定的 interrupt-turn;讓/permissions理解並顯示具名 permission profiles;讓封裝版 Codex builds 在支援的 macOS 與 Linux 上使用 bundled patched zsh helper;並為 thread 與 turn APIs 在 Python SDK 中加入易懂的Sandboxpresets。錯誤修正涵蓋 TUI markdown rendering、macOS/Zellij output stability、slash-command completion draft preservation、tmux/iTerm control-modeCtrl-C、@app-mention filtering,以及 resume-flow cwd handling。 ↩↩