如何让 Codex 长时间工作
1. Codex 里对应长任务的 3 类机制
Automationscodex execCloud / Worktree

2. 什么时候用哪一种
| 方式 | 最适合什么 |
|---|---|
Automations | 定时巡检、日报、固定流程 |
codex exec | CI、脚本、非交互一次性执行 |
Cloud / Worktree | 长功能开发、后台推进、多轮改进 |
3. 一个最典型的 codex exec 示例
bash
codex exec --full-auto --sandbox workspace-write \
"Read the repository, run the test suite, identify the minimal fix, implement it, and stop."4. 一条很稳的教学顺序
- 先学
Worktree - 再学
Cloud - 再学
Automations - 最后学
codex exec
因为它符合从“人盯着”到“半自动”再到“全自动”的理解路径。
5. 最容易出问题的地方
- 没有验收标准就让任务长时间跑
- 没有隔离环境就直接改主工作区
- 自动化里没有明确输出要求
- 执行完没有回收结果和复核