Guide

Know when a Codex task is waiting for you

Updated

Also in: Deutsch, Français, Español, Português

On this page

The Codex CLI can send a desktop notification or terminal bell (BEL) when a turn finishes and when it stops to ask for approval. Configure both under [tui] in ~/.codex/config.toml, or run your own script with notify and PermissionRequest hooks. When you run several sessions at once, a display that shows which one is waiting saves you hunting through windows.

Orbtile showing live coding agent sessions on a Mac panel, a Logitech MX Creative Keypad and an iPhone

1. Terminal notifications

Add this to ~/.codex/config.toml:

[tui]
notifications = ["agent-turn-complete", "approval-requested"]

notifications = true turns them all on; a list keeps only the events you name. Two more settings go in the same table:

  • notification_condition: "unfocused" is the default and fires TUI notifications only when the terminal is unfocused, while "always" fires them every time.
  • notification_method: "auto" is the default and prefers OSC 9 notifications before falling back to BEL, or you can set "osc9" or "bel".

Running codex with no subcommand launches the interactive terminal UI (TUI), where notifications are built in and on by default. OSC 9 is a terminal escape sequence that some terminals show as a desktop notification. BEL is the \x07 character.

Codex stores its local state under CODEX_HOME, which defaults to ~/.codex. Project-scoped .codex/config.toml files cannot override machine-local notification settings, so set notification keys in your user-level ~/.codex/config.toml, or pass a one-off TOML override from the CLI with -c or --config.

2. Run your own program when a turn finishes

notify runs a program after every turn and passes it one JSON argument. Root keys must appear before tables in TOML, so put it near the top of the file, above any [table] line:

notify = ["python3", "/path/to/notify.py"]

The JSON includes type (agent-turn-complete), thread-id, turn-id, cwd, input-messages and last-assistant-message. On macOS, OpenAI's example script uses terminal-notifier to show a turn-completion notification:

#!/usr/bin/env python3
import argparse
import json
import subprocess
import sys

def main() -> int:
    parser = argparse.ArgumentParser(
        description="Show a Codex turn-completion notification on macOS."
    )
    parser.add_argument("notification", type=json.loads, help="Codex notification JSON")
    notification = parser.parse_args().notification
    if notification.get("type") != "agent-turn-complete":
        return 0
    title = f"Codex: {notification.get('last-assistant-message', 'Turn Complete!')}"
    message = " ".join(notification.get("input-messages", []))
    subprocess.check_output(
        [
            "terminal-notifier",
            "-title",
            title,
            "-message",
            message,
            "-group",
            "codex-" + notification.get("thread-id", ""),
            "-activate",
            "com.googlecode.iterm2",
        ]
    )
    return 0

if __name__ == "__main__":
    sys.exit(main())

notify only fires when a turn completes. For approval requests, use the approval-requested notification above.

Codex ignores notify when it appears in a project-local .codex/config.toml file and prints a startup warning, so configure notify in your user-level ~/.codex/config.toml.

For how the CLI installs, loads config.toml and AGENTS.md, and runs non-interactively with codex exec, see OpenAI Codex CLI: install, commands, config.toml and codex exec.

Run a script on approval requests with PermissionRequest hooks

Because notify currently fires only on agent-turn-complete, use a PermissionRequest lifecycle hook when you want to run an external command as soon as Codex is about to ask for approval, such as a shell escalation or a managed-network approval. PermissionRequest does not run for commands that do not need approval.

{
  "hooks": {
    "PermissionRequest": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "/usr/bin/python3 \"$(git rev-parse --show-toplevel)/.codex/hooks/permission_request.py\"",
            "statusMessage": "Checking approval request"
          }
        ]
      }
    ]
  }
}
  • Where hooks load: local Codex reads hooks from hooks.json or inline [hooks] tables in config.toml across user, system and trusted project layers.
  • Matcher filter: on PermissionRequest, the matcher regex is applied to tool_name, with values such as Bash, apply_patch and MCP tool names, and "*" matches every tool.
  • Standard input payload: each command hook receives one JSON object on stdin with session_id, turn_id, cwd, model, permission_mode, tool_name and tool_input.
  • Alert-only hooks: if your hook exits 0 with no output, it makes no decision and Codex uses its normal approval flow.
  • Review and trust: non-managed hooks are skipped until you review and trust their current hash using the /hooks command in the CLI.
  • Background hooks: add "async": true in hooks.json, or async = true in config.toml, so alert scripts run while Codex continues.

If a single configuration layer defines hooks in both hooks.json and config.toml, Codex loads both and warns at startup, so prefer one format per layer. Hooks are enabled by default and can be turned off by setting hooks = false under [features] in config.toml.

By default, Codex waits for a command hook to finish before continuing. Background hooks run up to eight concurrently per session, and extra hooks wait until a running one finishes. Because background hooks cannot block, approve, rewrite or otherwise control the triggering operation, they fit alert-only scripts, while synchronous hooks handle tool policies and permission decisions. Unfinished background hooks are cancelled when the session ends, and SessionEnd hooks always run synchronously.

Codex commands and configuration precedence

Built-in Codex CLI commands and flags let you inspect active approval settings, review hooks and check which configuration layer won:

  • /hooks: lists hook sources so you can review new or changed hooks, trust them or disable individual non-managed hooks.
  • /permissions: adjusts approval and sandbox settings inside the current session.
  • /status: shows the active model, approval policy, writable roots and token usage for the current session.
  • /debug-config: shows the configuration layers in precedence order and the source of managed policy requirements.

From the shell, codex exec runs scripted non-interactive tasks, and adding --json prints newline-delimited JSON events, one per state change. Start Codex with --strict-config to treat unrecognised config.toml keys as errors instead of ignoring them. Use --ask-for-approval or -a with on-request or never to control when Codex pauses for approval, or pass --approve-for-me for automatic approval review with on-request approvals and the workspace-write sandbox.

When a notification or approval setting does not behave as expected, check which layer took precedence. Codex resolves configuration values in this order, highest precedence first:

  • CLI flags and overrides: command-line flags and --config values override every file layer for that run.
  • Project config: .codex/config.toml files from the project root to your working directory apply in trusted projects only, with the closest file winning.
  • Profile files: files selected with --profile profile-name load from ~/.codex/profile-name.config.toml.
  • User config: personal defaults live in ~/.codex/config.toml.
  • Cloud-managed defaults: workspace config.toml defaults apply when delivered for the signed-in workspace.
  • System config: /etc/codex/config.toml loads on Unix when present.
  • Built-in defaults: Codex falls back to its built-in defaults when no higher layer sets a key.

If a project is untrusted, Codex skips project-scoped .codex/ layers including project-local config, hooks and rules, while user and system config still load.

Desktop app, IDE extension and mobile notifications

Notification controls and delivery channels vary across Codex surfaces:

  • Desktop app alerts: open Settings in the ChatGPT desktop app to set turn-completion alerts to appear never, only while ChatGPT is in the background, or always.
  • Permission and question toggles: separate controls in the ChatGPT desktop app Settings turn permission and question notifications on or off.
  • Activity view: select the sidebar bell, or press Cmd+Option+U on macOS or Ctrl+Alt+U on Windows, to see unread, running or waiting chats.
  • Floating pet: in the ChatGPT desktop app, an optional floating pet shows when a chat is Running, Needs input, Ready or Blocked.
  • IDE extension: the IDE extension has no separate notification controls, so keep the chat open or configure notify on the connected Codex host.
  • Mobile notifications: pair the ChatGPT mobile app with an awake, online macOS or Windows desktop app host to get notified and approve actions.
  • ChatGPT web alerts: open Settings > Notifications on ChatGPT web to manage notification categories and channels, which can include push, email or SMS.
  • CLI terminal pets: enter /pets or /pet in the CLI to show Running, Needs input, Ready and Blocked for the current session.
  • Codex Micro: this limited-run collaboration between Codex and Work Louder follows up to six ChatGPT desktop app chats on frosted Agent Keys.

To set up mobile access, open the ChatGPT desktop app on the host computer, go to Settings > Connections > Control this Mac or PC, select Set up or Add, and scan the QR code from your iOS or Android phone. Mobile setup starts from the desktop app and cannot be set up from the Codex CLI or IDE extension. Once connected, open Codex in the ChatGPT mobile app on iOS, or Remote if your app still shows that label, to receive notifications when work completes or needs your attention.

A terminal pet follows the current CLI session without the desktop app's multiple-chat activity tray, and /pets off disables it. Terminal pets require iTerm2 3.6 or later, or a terminal with Kitty graphics or Sixel support, and are unavailable inside tmux and Zellij. On Codex Micro, the six Agent Keys light White for Idle, Blue for Thinking, Green for Complete, Amber for Requires input, Red for Error and stay off when unassigned.

Which one to use

You wantUse
To know when a turn ends or Codex needs approval[tui] notifications
Your own sound, banner or messagenotify with a script
To run a script when Codex asks for tool approvalA PermissionRequest hook in hooks.json or config.toml
To run an alert script without pausing CodexA background command hook with "async": true in hooks.json
Alerts, an Activity view or a floating pet on desktopChatGPT desktop app Settings and Cmd+Option+U (Ctrl+Alt+U on Windows)
Push, email or SMS alerts on ChatGPT webSettings > Notifications on ChatGPT web
Phone alerts and remote approvals for desktop chatsChatGPT mobile app paired in Settings > Connections > Control this Mac or PC
To see which of several sessions is waitingA display that shows every session

When notifications aren't enough

A notification tells you that some Codex session needs you. With a desktop chat, two terminal sessions and a codex exec run going, you still have to find which one.

Orbtile shows every Codex session as its own key on the Logitech MX Creative Keypad, or a tile on an iPhone or Android phone: desktop app chats, terminal sessions and codex exec runs. It reads Codex's own thread files, so there's nothing to install. A waiting session glows magenta-violet and moves to the front. From the keys you can answer the Codex desktop app's command approvals and its supported multiple-choice questions. For a terminal session's command approval, the keys offer Allow; to say no, answer in the terminal. Anything else shows Answer on computer.

When you leave your desk, Orbtile Away connects Orbtile Mobile on iPhone or Android to your computer over mobile networks or another Wi-Fi network, even while your computer screen is locked. It sends push notifications when an agent is waiting and lets you review and answer approvals, answer multiple-choice questions and send follow-up instructions from your phone. On macOS and Windows, OpenAI Codex CLI and Codex Desktop work with Orbtile Away automatically with no hooks to install, while private --no-daemon CLI sessions stay on your computer.

For Kimi Code's terminal and web UI alerts, see Kimi Code notifications: hooks, NotifyUser and TUI settings.

FAQ

Why doesn't notify fire when Codex asks for approval?

It only runs when a turn completes. Add approval-requested to tui.notifications in ~/.codex/config.toml, or configure a PermissionRequest hook to run a script when Codex is about to ask for approval.

Can I get notified even when the terminal is in front?

Yes. Set notification_condition to always under the tui table in ~/.codex/config.toml.

Does Orbtile change my Codex config?

Not unless you ask it to. Optional Codex hooks add a compacting state and slightly earlier updates; if you install them from Orbtile's settings, you review and trust them in Codex first.

Does it work on Windows?

Yes. Orbtile runs on Windows 11 and supports Codex there, along with Claude Code, ZCode, Antigravity and Kimi Code.