All guides

Running several Codex sessions: knowing which one needs you

Updated 19 November 2026 · 4 min read

When you run several Codex CLI sessions at once, a plain "Codex has finished" alert isn't enough, because you can't tell which session sent it. The fix is to put the session's project or folder in every notification. Every hook receives the session's cwd and session_id as JSON, so your hook can read them and include the project name in the alert. Use codex --worktree so parallel sessions on one repository each get their own folder, name chats with /rename, and set the terminal title with /title so each window says what it is.

01Put the project in every alert

Every Codex hook gets JSON on stdin that includes:

  • cwd: the session's working folder, such as /Users/you/code/billing-svc;
  • session_id: a unique id for the session;
  • for Stop, last_assistant_message: what Codex just said;
  • for PermissionRequest, tool_input.command: what it wants to run.

A small script turns that into a useful title. This one works on Mac and Linux (swap the last line for your system's notifier):

#!/bin/sh
# ~/.codex/hooks/notify-project.sh
input=$(cat)
read -r project event <<EOF
$(printf '%s' "$input" | python3 -c 'import json,os,sys; e=json.load(sys.stdin); print(os.path.basename(e.get("cwd","")), e.get("hook_event_name",""))')
EOF
case "$event" in
  Stop) text="finished" ;;
  PermissionRequest) text="wants approval" ;;
  *) exit 0 ;;
esac
osascript -e "display notification \"$text\" with title \"Codex: $project\"" >/dev/null 2>&1
exit 0

Register it for both Stop and PermissionRequest in ~/.codex/hooks.json and trust it in /hooks. Your alerts now read "Codex: billing-svc, wants approval".

With notify, the same information arrives as cwd and thread-id in the JSON argument. See the notify guide.

02Give parallel sessions their own folders

Two sessions in the same checkout will edit the same files and show the same folder name in every alert. Codex can start a session in a new managed Git worktree:

codex --worktree

Each session then works in its own folder on its own branch, and the folder name in your notifications tells them apart. You can also make worktrees yourself with git worktree add ../billing-svc-pagination and start codex in each.

03Name sessions and windows

  • /rename gives the current chat a name you'll recognise in /resume and codex resume.
  • /title sets what the terminal window or tab title shows, such as the project, status and thread, so a glance at your tabs tells you which one is waiting.
  • tmux window names do the same in tmux: tmux new-window -n billing-svc. See Codex in tmux.
  • codex agents opens a command center to browse chats and switch between sessions on a shared server.

04Sending answers to the right session

A one-way alert only needs the right label. A two-way tool also has to send your answer to the right session, which is harder: several hooks may be waiting at once, from different projects.

Notifier for Codex handles this per request. Each approval, question or "finished" push on the iPhone or Android app carries the project name and the computer it came from, and your answer goes back to the hook that is waiting for it, in that session. If several requests are waiting, the app lists them, and you can answer them in any order.

It also scales across computers. One phone can pair with several computers, Mac, Windows and Linux alike, and each alert says which one it came from. codex-notifier pair --name work-laptop sets the name a computer shows on your phone. Notifier for Codex is independent and not affiliated with OpenAI.

05Subagents

Codex can spawn subagents within one session. They fire their own SubagentStart and SubagentStop events, and their hooks receive the parent session's id. If you only want one "finished" alert per session, hook Stop (the main turn) and leave SubagentStop alone.

06FAQ

How do I tell which Codex session finished?

Read cwd from the hook's input and put the folder name in the notification title. With worktrees, each session has a distinct folder.

Can two Codex sessions share one hooks.json?

Yes. Every session on the computer reads the same ~/.codex/hooks.json. The hook runs separately for each session, with that session's details on stdin.

Will parallel sessions slow each other down through hooks?

Each hook run is a separate process for its own session, so one session's hook doesn't hold up another's. Keep hooks fast or async anyway.

Can I answer two waiting approvals from my phone?

With Notifier for Codex, yes. Each request is answered separately and goes back to its own session.

Notifier for Codex Get a push on your phone when Codex finishes or needs you, then approve, reject or answer from there. The codex-notifier command line tool is free on Mac, Windows and Linux.