## はじめに
3種類のパターンがある。
1. AIエージェントのターンが完了したとき
2. コマンド実行権限を確認するとき
3. プランの実装可否を確認するとき
動作確認は[[cmux]]。
## 概要
基本的には以下2点。
- アクティブではないときは[[Codex CLI]]が勝手に通知してくれる
- アクティブなときは[[Codex CLI]]は通知して**くれない**
- 代替案が必要
### **アクティブ** の定義
> **[[ワークスペース (cmux)|ワークスペース]]がアクティブ ([[cmux]]はアクティブでなくてもよい) な場合** を指す
### 参考
<div class="link-card-v2">
<div class="link-card-v2-site">
<img class="link-card-v2-site-icon" src="https://developers.openai.com/favicon.png" />
<span class="link-card-v2-site-name">developers.openai.com</span>
</div>
<div class="link-card-v2-title">
Advanced Configuration
</div>
<div class="link-card-v2-content">
More advanced configuration options for Codex local clients
</div>
<img class="link-card-v2-image" src="https://developers.openai.com/open-graph.png" />
<a href="https://developers.openai.com/codex/config-advanced/#notifications"></a>
</div>
## AIエージェントのターンが完了したとき
### アクティブな場合
`config.toml` に `notify` を指定し、その中で通知スクリプトを書く。
`config.toml`
```toml
notify = ["bash", "/Users/tadashi-aikawa/.codex/notify_macos.sh"]
```
`notify_macos.sh`
```bash
#!/bin/bash
notify() {
local title="$1"
local body="$2"
printf '\e]777;notify;%s;%s\a' "$title" "$body" >/dev/tty
}
LAST_MESSAGE=$(echo "$1" | jq -r '.["last-assistant-message"] // "Codex task completed"')
notify "🤖Codex" "$LAST_MESSAGE"
```
### アクティブではない場合
何もしなくても通知される。[[Codex CLI]] v0.81.0 から対応されたらしい。
## コマンド実行権限の許可を得るとき
### アクティブな場合
❌ **通知する方法はない。(2026/02/23 時点)**
`notify` が対応しているtypeは `agent-turn-complete` のみなので [[#AIエージェントのターンが完了したとき]]以外は手出しできない。。
### アクティブではない場合
何もしなくても通知される。[[Codex CLI]] v0.81.0 から対応されたらしい。
## プランの実装可否を確認するとき
### アクティブな場合
❌ **通知する方法はない。(2026/02/23 時点)**
`notify` が対応しているtypeは `agent-turn-complete` のみなので [[#AIエージェントのターンが完了したとき]]以外は手出しできない。。
> Use `notify` to trigger an external program whenever Codex emits supported events (currently only `agent-turn-complete`). This is handy for desktop toasts, chat webhooks, CI updates, or any side-channel alerting that the built-in TUI notifications don’t cover.
> *[Advanced Configuration](https://developers.openai.com/codex/config-advanced/#notifications)*
### アクティブではない場合
何もしなくても通知される。[[Codex CLI]] v0.81.0 から対応されたらしい。
## 未解決問題に関するissue
<div class="link-card-v2">
<div class="link-card-v2-site">
<img class="link-card-v2-site-icon" src="https://github.githubassets.com/favicons/favicon.svg" />
<span class="link-card-v2-site-name">GitHub</span>
</div>
<div class="link-card-v2-title">
Event Hooks · Issue #2109 · openai/codex
</div>
<div class="link-card-v2-content">
Let us define event hooks with pattern matching, to trigger scripts/commands before/after codex behaviors.
</div>
<img class="link-card-v2-image" src="https://opengraph.githubassets.com/a70912dd42f8471bde0dc8cd2d0a189925122efa03c3947a6fc13d21143976cd/openai/codex/issues/2109" />
<a href="https://github.com/openai/codex/issues/2109"></a>
</div>