Skip to content

Codex

Codex can run a program each time it finishes a turn. Point it at a small script and each finished turn arrives as a notification, with Codex’s last message and the project.

  1. In the Pocketbell app, create a Source for Codex and copy its key.

  2. Save this as ~/.codex/pocketbell.py, with your key in it:

    import json, os, sys, urllib.request
    KEY = "pb_live_…"
    event = json.loads(sys.argv[1])
    if event.get("type") == "agent-turn-complete":
    project = os.path.basename(event.get("cwd", "")) or "Codex"
    message = (event.get("last-assistant-message") or "Finished.")[:1000]
    body = json.dumps({"title": f"Codex: {project}", "message": message}).encode()
    request = urllib.request.Request(
    "https://api.pocketbell.dev/v1/messages",
    data=body,
    headers={"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"},
    )
    urllib.request.urlopen(request, timeout=10)
  3. In ~/.codex/config.toml:

    notify = ["python3", "/Users/you/.codex/pocketbell.py"]

Codex runs the script after every turn, so every finished turn notifies you. Set the Source’s priority to Quiet for a silent note in the inbox, or Normal to hear it.

Codex calls this program only when a turn finishes, not when it’s waiting for your approval, so its approvals stay in the terminal.