Repository navigation
fix(live): steer a busy Codex TUI through its composer - #182
Merged
Merged
Conversation
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`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The reported difference between
live send(CLI) and the MCPsend_messagetool does not exist in the code. Both callrouter.sendwith the same defaults (when="now", no fyi), and both deliver to Codex withcodex queue. Neither steered a busy Codex.Why
codex queuecan't steer: a Codex TUI runs its thread in its own process. The app-server daemon lists only one thread, acodex resumesession, and returnsnotLoadedfor the spawned TUIs. The TUI reads~/.codex/queue_1.sqliteonly 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 25calls in one turn, with orders to printRECEIVED <codeword>between calls:live send(codex queue)send_message(codex queue)RECEIVED BRAVOFix.
codex.deliverfirst looks for the session's exact tmux pane:live spawn's record, or its thread id incodex 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 shortcutsfooter. 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 throughcodex 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 -psession. From another main session,live send … --yesprinteddelivered to its composer. The rollout shows DELTA at 14:30:10 andRECEIVED DELTAat 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.