DEV Community

agentyak
agentyak

Posted on AI-assisted

Codex CLI notifications on your phone: notify, tui.notifications or hooks?

Codex has three different ways to tell you something happened, and they're easy to mix up. Only two of them can reach a phone, and only one can tell you Codex is waiting for approval. Here's what each does, checked against the Codex config reference and advanced config docs.

1. tui.notifications: desktop only

Built into the terminal UI. In ~/.codex/config.toml:

[tui]
notifications = ["agent-turn-complete", "approval-requested"]
notification_condition = "always"   # default "unfocused"
Enter fullscreen mode Exit fullscreen mode
  • Covers: turn complete and approval requested.
  • Reaches: your terminal or desktop, through an OSC 9 escape or a BEL. Not your phone.
  • Good for: working at your desk with Codex in another window.

2. notify: runs a program when a turn completes

Also in config.toml. Codex runs the command and passes one JSON argument. Currently the only event is agent-turn-complete, and the payload includes last-assistant-message. Here it is pushing to an ntfy topic:

notify = ["sh", "-c", "printf %s \"$1\" | jq -r '\"Codex: \" + ((.\"last-assistant-message\" // \"turn complete\")[:200])' | curl -s --data-binary @- ntfy.sh/your-secret-topic", "--"]
Enter fullscreen mode Exit fullscreen mode

(The trailing "--" becomes $0, so the JSON lands in $1.)

  • Covers: turn complete only. No event when Codex is waiting for approval.
  • Reaches: anything you can curl: ntfy, Slack, a webhook.
  • Watch out: notify must go in your user-level ~/.codex/config.toml. Codex ignores it in a project's .codex/config.toml.

3. Hooks: turn complete and waiting for approval

Codex hooks (~/.codex/hooks.json) run a command on events like Stop and PermissionRequest, with the event as JSON on stdin. That's the one route that reaches your phone for both "done" and "waiting for you".

Disclosure: the hook example I use sends to agentyak, which I work on. It gives Codex an address and you a chat with it, so you can reply from your phone:

"Stop": [{ "hooks": [{ "type": "command", "timeout": 10,
  "command": "jq -c '{chat: \"@alex\", text: (\"Codex finished in \" + (.cwd | split(\"/\") | last) + \": \" + ((.last_assistant_message // \"\")[:300]))}' | curl -sS https://agentyak.com/send_message -H \"Authorization: Bearer $(cat ~/.agentyak/ID/key)\" --data @- > /dev/null || true" }] }]
Enter fullscreen mode Exit fullscreen mode

You can point the same hooks at ntfy instead if you only want a one-way ping. Two gotchas apply either way. Codex runs a new hook only after you trust it in /hooks. And its default sandbox has no network, so approve the setup curl the first time.

Full setup, with the PermissionRequest hook too: phone notification when Codex finishes.

Which one?

You want Use
A desktop alert while you're at the computer tui.notifications
A phone ping when a turn ends, simplest setup notify → ntfy
A phone ping for "done" and "waiting for approval" hooks
To reply from your phone hooks → a chat (e.g. agentyak)

AI-assisted.

Top comments (0)