Skip to content

fix(live): steer a busy Codex TUI through its composer - #182

Merged
ClementWalter merged 1 commit into
mainfrom
fix/live-codex-steer
Dec 4, 2026
Merged

ClementWalter merged 1 commit into
mainfrom
fix/live-codex-steer

Conversation

@ClementWalter

Copy link
Copy Markdown
Owner

The reported difference between live send (CLI) and the MCP send_message tool does not exist in the code. Both call router.send with the same defaults (when="now", no fyi), and both deliver to Codex with codex queue. Neither steered a busy Codex.

Why codex queue can't steer: a Codex TUI runs its thread in its own process. The app-server daemon lists only one thread, a codex resume session, and returns notLoaded for the spawned TUIs. The TUI reads ~/.codex/queue_1.sqlite only when its turn ends. The docs-peer Codex today (codex:01a24149-491e…) still has 17 undelivered items in that queue. Its rollout shows no lead message arriving as a user turn: it read the lead's messages through tool calls, which looks like steering.

I reproduced it on a busy spawned Codex. It ran eight sleep 25 calls in one turn, with orders to print RECEIVED <codeword> between calls:

Codeword Path Arrived
ALPHA CLI live send (codex queue) 14:26:58, as a new turn after the run ended
CHARLIE MCP send_message (codex queue) 14:27:00, as a new turn after the run ended
BRAVO typed into the TUI's composer 14:24:53, at the next tool boundary: RECEIVED BRAVO

Fix. codex.deliver first looks for the session's exact tmux pane: live spawn's record, or its thread id in codex resume <id>. It never guesses from the folder. If it finds the pane, it pastes the message in brackets, waits 0.5 s (an Enter right after a paste is read as a newline) and presses Enter. It only types under an empty, focused composer, which shows the ? for shortcuts footer. An approval prompt (checked on a real ask-mode Codex: Press enter to confirm) or a draft hides that footer, so those messages still go through codex queue. Otherwise an Enter would approve a command. Both the CLI and MCP paths get this behavior.

Proof with the fix: I spawned a busy Codex from a main claude -p session. From another main session, live send … --yes printed delivered to its composer. The rollout shows DELTA at 14:30:10 and RECEIVED DELTA at 14:30:15, inside the same turn.

Limit: there is a short gap between checking the screen and pasting. A prompt that opens in that gap would get the message and its Enter.

Nothing to do before merge or deploy.

Both live send and the MCP send_message delivered to Codex with `codex queue`.
A TUI runs its thread in its own process, not in the daemon, and reads that
queue only when its turn ends, so neither path steered a running agent: the
spawned docs Codex had 17 queued messages it never got as turns.

A Codex whose tmux pane is known exactly (`live spawn`'s record or its thread
id in `codex resume <id>`) now gets the message pasted into its composer
(bracketed) and submitted, which Codex takes at the next tool boundary. It
types only under an empty composer, recognised by the "? for shortcuts"
footer: an approval prompt would take the Enter as its answer. Everything
else keeps `codex queue`.
@ClementWalter
ClementWalter merged commit 7d35138 into main Dec 4, 2026
5 checks passed
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.

1 participant