Codex Agent banner
dztabel-happy dztabel-happy

Codex Agent

Development community

Description

让 OpenClaw 以“受控运行时”的方式操作 Codex CLI,而不是只靠一堆临时 tmux 命令。

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

Codex Agent

让 OpenClaw 以“受控运行时”的方式操作 Codex CLI,而不是只靠一堆临时 tmux 命令。

当前基线

  • 校验日期:2026-03-24
  • 本机 Codex:codex-cli 0.116.0-alpha.10
  • 本机 OpenClaw:OpenClaw 2026.3.11
  • 本机默认 Codex 配置:model = "gpt-5.4"model_reasoning_effort = "xhigh"web_search = "live"

这次升级的核心目标有两个:

  1. 把旧版文档里已经过时的 Codex / OpenClaw 认知清掉。
  2. 把运行时做成可追踪、可恢复、可验证,而不是“启动了就全靠运气”。

现在它能做什么

  • `hooks/start_codex.sh` 启动一个受管的交互式 Codex tmux 会话。
  • `hooks/run_codex.sh` 启动一个受管的 codex exec 一次性任务。
  • 把每个会话登记到 ~/.openclaw/runtime/codex-agent/ 下,保留 session_keyopenclaw_session_id、日志、输出和状态。
  • `runtime/list_sessions.sh` / `runtime/session_status.sh` 查看会话。
  • 交互式启动会先用干净的 bash --noprofile --norc bootstrap Codex,避免用户 shell init / conda 异常在 TUI 启动前把 pane 卡死。
  • 识别并处理 Codex 启动阶段的新阻塞点:
    • 自更新提示 Update available! ... Press enter to continue
    • 目录信任提示 Do you trust the contents of this directory?
  • 在审批、完成通知和重新唤醒 OpenClaw 时显式传 --session-id,避免消息飘到错误上下文。
  • 把日志和 monitor PID 都收进私有 runtime 目录,避免继续把敏感数据裸写到 /tmp
  • on_complete.py 的外发摘要做脱敏和裁剪,避免把完整回复原样发到聊天通道。

为什么旧版需要大修

旧仓库里最明显的过时点有这些:

  • 版本状态还停在 0.104.0,但本机已经是 0.116.0-alpha.10
  • 文档仍把 gpt-5.2 当默认模型,而本机实际默认已经是 gpt-5.4
  • 旧知识库还把 steercollaboration_modessqlite 当可用 feature,但当前 CLI 已把它们标成 removed
  • 旧说明把 OpenClaw session reset 描述成“每天凌晨 4 点自动重置”,这和当前官方文档/本机 CLI 的说法不一致。现在应按 session.reset.modeidleMinutes 来理解,文档默认值是 60 分钟空闲过期。
  • 旧 hook 只按“审批提示”匹配 pane 内容,没覆盖 Codex 的新更新提示和 trust 提示,所以会出现“脚本显示启动成功,实际上 UI 卡在启动页”的假成功。

架构原则

本项目参考了 `/Users/abel/project/claude-code-agent` 的一些好思路,但没有照搬 Claude 的设计。

保留的思路:

  • 稳定 session_key
  • 稳定 openclaw_session_id
  • 会话 runtime registry
  • 显式状态查询
  • wake 去重

没有照搬的部分:

  • Claude 专用 hook 生命周期
  • Claude 权限回调模型
  • Claude 风格的本地/接管双控制面

Codex 这边仍然坚持“Codex 原生命令 + tmux + noti