Skip to content

fix(cookbook): stop mailbox-chat misrouting under the Codex shared daemon - #979

Merged
umputun merged 3 commits into
masterfrom
mailbox-chat-daemon-guard
Nov 12, 2026
Merged

umputun merged 3 commits into
masterfrom
mailbox-chat-daemon-guard

Conversation

@umputun

@umputun umputun commented Nov 12, 2026

Copy link
Copy Markdown
Owner

the two-agent-mailbox-chat recipe misroutes mail when Codex runs on its shared app-server daemon, which is what a plain codex does without --no-daemon. The daemon runs every client's hooks and commands with the AGTERM_* ids of the pane that started it, so the Codex SessionStart hook registered each new thread under that pane with the daemon's pid. The starting pane's mail then went to whichever thread started last, and the registration never expired because the daemon outlives every Codex TUI. say and status from such a Codex also sent as the starting pane.

The recipe now detects the daemon (the nearest codex ancestor runs the app-server subcommand) and refuses to act from it:

  • the SessionStart hook registers nothing when it runs under the daemon
  • a registration the daemon made before this change is ignored, so an in-place upgrade stops misrouting without restarting anything
  • say, status and deliver under the daemon exit with an error naming --no-daemon

A daemon-backed Codex now reports receiver: none and its mail waits in its own mailbox until it is restarted with the launch line from Setup. --no-daemon and plain-shell use are unchanged. The README's Limits section says this.

The root cause is upstream, openai/codex#48500.

Related to #977

…emon

A Codex started without --no-daemon runs its hooks and commands in the shared
app-server, which carries the AGTERM_* ids of the pane that started it. The
SessionStart hook registered every such thread under that pane with the daemon's
pid, so the starting pane's mail went to whichever thread started last, and the
registration never went stale because the daemon outlives every TUI. `say` and
`status` from such a Codex sent as the starting pane.

The hook now skips a start whose nearest codex is the app-server, a registration
held by the app-server is ignored, and own_identity refuses under it with an
error naming --no-daemon. A daemon-backed Codex reports receiver: none and its
mail waits in its own mailbox.

Related to #977
Copilot AI balanced review requested due to automatic review settings November 12, 2026 13:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Deploying agterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: c6a6d62
Status: ✅  Deploy successful!
Preview URL: https://ab065c9d.agterm.pages.dev
Branch Preview URL: https://mailbox-chat-daemon-guard.agterm.pages.dev

View logs

@umputun
umputun merged commit ed7e2cd into master Nov 12, 2026
9 checks passed
@umputun
umputun deleted the mailbox-chat-daemon-guard branch November 12, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants