// codex.com · 自主完成编程任务 · 基于 codex-1 模型
| 属性 | 说明 |
|---|---|
| 发布时间 | 2025 年 |
| 访问入口 | codex.com |
| 核心定位 | 自主编程 Agent |
| 背后模型 | codex-1(基于 o3/o4 优化) |
| 运行方式 | 后台长时间自主执行 |
| 输出形式 | 代码变更 + PR + 测试结果 |
| 产品 | 类型 | 核心差异 |
|---|---|---|
| Codex | Agent 级 | 后台自主执行任务,无需逐步引导 |
| ChatGPT | 对话式 | 一问一答,需要用户持续参与 |
| GitHub Copilot | 补全级 | 实时代码补全,不独立完成任务 |
| Claude Code | Agent 级 | 命令行,需本地环境 |
| 区域 | 功能说明 |
|---|---|
| Tasks | 所有任务的状态总览列表 |
| New Task | 描述任务的自然语言输入框 |
| Repository | 连接并选择 GitHub 仓库 |
| Environment | 代码运行的沙盒环境配置 |
| Timeline | 任务执行的每一步操作记录 |
| Diff 视图 | 文件变更的 before/after 对比 |
| Terminal 日志 | Codex 执行的命令和输出 |
// 任务生命周期
Queued // 排队等待执行
↓
Running // 正在执行(可查看 Timeline)
↓
Needs Review // 等待用户审查 Diff
↓
Completed // 已批准并合并
// 异常状态
Failed // 执行失败(可查看错误日志)
Cancelled // 用户手动取消
// 并发支持
// 可同时运行多个任务
// 互不干扰,各自独立环境
// 新建任务:支持自然语言描述
"Fix the login bug where users are
logged out after page refresh"
"Add rate limiting to the /api/users
endpoint, max 100 req/min per IP"
"Refactor auth.js to use async/await
instead of callback pattern"
// 任务操作
Cancel // 取消正在运行的任务
Retry // 重试失败的任务
Clone // 复制任务描述,微调后重新提交
// 任务描述技巧
// ✓ 包含具体文件路径或函数名
// ✓ 说明预期行为(不只是问题描述)
// ✓ 附上相关错误信息或测试用例
codex/<task-slug>-<id>
| 特性 | 说明 |
|---|---|
| 隔离性 | 每个任务独立云端容器 |
| 依赖安装 | 自动检测并运行 pip / npm / yarn |
| 测试运行 | 自动执行 pytest / jest / go test 等 |
| 网络访问 | 可配置,默认受限 |
| 存储 | 任务结束后环境销毁 |
# .codex/setup.sh 或在界面配置
pip install -r requirements.txt
npm install
cp .env.example .env
| 模式 | 行为 | 适用场景 |
|---|---|---|
| Ask Mode | 只解释,不修改文件 | 理解代码、排查思路、询问最佳实践 |
| Agent Mode | 自主执行,修改文件 | 实际修复、实现功能、重构代码 |
"Why does the user session expire
unexpectedly? Explain the auth flow
in auth/middleware.ts"
"What's the performance bottleneck
in the database query in user.py?"
# Python 项目示例
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
python manage.py migrate
# Node.js 项目示例
npm install
cp .env.example .env
npm run db:seed
# Go 项目示例
go mod download
make build
# AGENTS.md 示例
## 代码风格
- 使用 4 空格缩进,不用 Tab
- 所有函数必须有 JSDoc 注释
- 变量命名使用 camelCase
## 测试要求
- 新功能必须有对应单元测试
- 使用 Jest,覆盖率不低于 80%
## 禁止操作
- 不得修改 config/prod.json
- 不得删除 /legacy 目录下文件
## 分支策略
- feature/* 用于新功能
- fix/* 用于 Bug 修复
Fix the bug described in Issue #{{issue_number}}.
Steps to reproduce: {{steps}}
Expected: {{expected}}
Actual: {{actual}}
Add a regression test to prevent recurrence.
Implement {{feature_name}} in {{file_path}}.
Requirements: {{requirements}}
Follow the existing code style.
Add unit tests with >80% coverage.
| 集成方式 | 说明 |
|---|---|
| GitHub Issues | 直接粘贴 Issue URL,自动读取问题描述 |
| Slack | 通过 Slack 触发任务,接收任务完成通知 |
| Webhook | 任务状态变化时推送 HTTP 事件 |
| API | 通过 REST API 程序化创建和管理任务 |
| CI/CD | 集成到 GitHub Actions 工作流 |
task.started / task.completed / task.failed / task.needs_review
https://github.com/org/repo/issues/142"Fix issue: https://github.com/org/repo/issues/142""Add user avatar upload feature to
the profile settings page.
Requirements:
- Accept JPG/PNG, max 2MB
- Resize to 200x200px on server
- Store in /uploads/avatars/
- Update the User model with
avatar_url field
- Add API endpoint PUT /api/profile/avatar
- Show preview before upload in UI"
"Improve test coverage for
src/services/payment.js from 40%
to at least 85%.
Use Jest. Cover edge cases:
- Payment failure handling
- Refund logic
- Concurrent transaction conflicts"
"Refactor all callback-style async
code in src/api/ to use async/await.
Maintain identical behavior.
Update all related tests."
getUser(id, function(err, user) {
if (err) {
return cb(err);
}
getOrders(user.id,
function(err, orders) {
if (err) return cb(err);
cb(null, orders);
});
});
async function getUserOrders(id) {
try {
const user = await getUser(id);
const orders =
await getOrders(user.id);
return orders;
} catch (err) {
throw err;
}
}
"Fix this production error.
Error occurs when users submit
large forms (>50 fields).
Stack trace:
TypeError: Cannot read properties
of undefined (reading 'validate')
at FormValidator.validate
(src/utils/validator.js:142)
at POST /api/forms/submit
(src/routes/forms.js:87)
Repro: Submit form with 51+ fields.
Expected: Form submits successfully.
Actual: 500 Internal Server Error."
rules.slice(0, limit) → rules.slice(0)