Repository navigation
Support waking Codex on background exec_command output #29865
Description
Proposal
Add an opt-in wake_on_output flag to unified exec_command so a long-running background command can re-enter Codex context when it emits output after the initial tool call has yielded.
Why
Today, exec_command can leave a process running and expose a session_id, but Codex only sees later output when it explicitly polls with write_stdin. This makes file/event-backed workflows awkward, especially commands that already block efficiently until a meaningful event arrives.
One concrete example is a channel/file-watch workflow where a helper blocks on filesystem events and prints a peer message only when the shared channel file changes. With an opt-in wake mechanism, the helper can be run once in the background and Codex can wake when a peer message arrives instead of burning turns on repeated bounded listens.
Suggested behavior
- Keep existing
exec_commandbehavior unchanged by default. - Add
wake_on_output: truefor explicit monitor/watch commands. - After the initial
exec_commandcall has yielded, batch subsequent process output and deliver it as a bounded synthetic user message. - Mark injected terminal output as untrusted data.
- Cap wake payloads so a noisy background process cannot dump unbounded context.
Patch branch
I have a working branch here for discussion, not an unsolicited PR:
https://github.com/fl4p/codex/tree/feat/wake-on-background-output
Implementation sketch in that branch:
- Adds
wake_on_outputto the unifiedexec_commandtool schema and request path. - Starts a background output waker only when the flag is true.
- Ignores output while the initial
exec_commandtool call is still active, so initial output is not duplicated as a wake. - Batches later output briefly, caps each wake at 4 KiB, and labels it untrusted.
- Uses the existing session steering/start-turn path to deliver the synthetic user message only when the session state allows it.
Local validation
On the patch branch:
just fmtpassedjust fix -p codex-corepassedjust test -p codex-core wake_on_outputpassedjust test -p codex-core background_output_wakepassedjust test -p codex-core shell_specpassed
A broad local just test -p codex-core run is not clean in my environment because of existing/local fixture problems, including missing test binaries and a unified-exec timeout that also reproduces from clean upstream HEAD.
Activity
github-actions commentedon Jun 24, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
fl4p commentedon Jun 24, 2026
Closing as a duplicate of #22003. I added the patch branch and validation details there: #22003 (comment)
Explicitly forbid backgrounding delegate calls: a documented codex CL…
docs: explain temporary cli-run workaround (openai/codex#42908, opena…