Add a “needs your attention” system notification to Codex: Codex Attention Notifier

I’ve整理 up the fix I just used locally for Codex’s missed notifications into a small tool:

I also posted it to the openai/codex discussion board:

What it solves: Codex’s default “turn finished” notification doesn’t cover all the scenarios where you actually need to come back and handle something. For example, when a task runs halfway and needs a permission approval, or when it’s about to run commands like sudo xcodebuild -license accept, installers, softwareupdate, etc. that are very likely to require an admin password—if the window isn’t in the foreground, it’s easy to assume Codex is still running, when in fact it’s already stuck waiting for you.

What it does:

  • Pops a macOS system notification when Codex emits a PermissionRequest.
  • Warns you in advance before running common commands that require manual intervention, e.g. sudo, xcodebuild -license, xcodebuild -runFirstLaunch, .pkg installer, softwareupdate, AppleScript administrator privileges.
  • Doesn’t notify for normal commands—so it won’t pop up for every ls, git, or build.
  • Only does notifications and logging; it won’t auto-approve/deny or rewrite Codex tool calls.
  • Logs to ~/.codex/logs/codex-attention-notifier.log.

Installation:

git clone https://github.com/constansino/codex-attention-notifier.git
cd codex-attention-notifier
python3 install.py

After installing, restart Codex Desktop, or start a new Codex session so the new hooks config takes effect.

You can test with this command—it won’t actually run sudo; it just simulates Codex hook input:

printf '%s\n' '{"hook_event_name":"PreToolUse","tool_name":"Bash","cwd":"'"$PWD"'","tool_input":{"command":"sudo xcodebuild -license accept"}}' \
  | python3 ~/.codex/hooks/codex_attention_notify.py

If it’s working, you’ll see a macOS notification, and you can also see the log:

tail -n 5 ~/.codex/logs/codex-attention-notifier.log

Limitations are also spelled out clearly: this isn’t an official first-class feature—just a practical patch built on Codex hooks. For the case where a subprocess has already started and then gets stuck on stdin/password, Codex currently doesn’t have a stable “waiting for input” event hook, so this tool covers common scenarios by identifying high-risk commands before execution.

更新一下:这个工具的默认安装方式已经改成只保留 PermissionRequest 通知,不再默认启用 PreToolUse。

原因是 Codex app 目前会把每一次 PreToolUse hook 都显示成“调用工具前”的记录。即使脚本内部判断普通命令后直接退出,UI 里还是会出现很多 hook 记录,实际体验会比较吵。

现在默认行为是:

  • Codex 真正发出权限请求时通知。
  • 不再每次 Bash 调用前运行 PreToolUse。
  • 所以不会再刷“调用工具前”记录。

对应的限制是:sudo Password: 这类子进程密码输入等待,默认方案不再提前兜底。Codex 目前还没有稳定的“子进程已经进入等待 stdin/password 状态”的 hook;如果强行用 PreToolUse 做前置识别,就会带来上面说的 UI 噪音。

仓库 README 和安装脚本已经更新: