Support injecting command output from background completion into the active Codex session
Is Codex missing a feature that you'd like to see? Feel free to propose it here.
Before you submit a feature:
- Search existing issues for similar features. If you find one, it rather than opening a new one.
- The Codex team will try to balance the varying needs of the community when prioritizing or rejecting new features. Not all features will be accepted.
See Contributing for more details.
What variant of Codex are you using?
CLI
What feature would you like to see?
Support a command-response injection path for background completions so an external watcher or orchestrator can deliver the completed command's output directly into the active Codex session as the next user turn, without requiring tmux send-keys or explicit polling. The intended workflow is:
- a background process watches an inbox file or similar event source
- when new output arrives, the watcher exits or emits a completion event
- Codex receives that output as input automatically in the active conversation context
- the session can then act on the injected content and continue the loop
This would make file-based or socket-based orchestration possible for agents that should wake Codex on process completion.
Additional information
I tested a file-watcher prototype where a background process writes JSONL output after new content arrives. In the current harness, the session does not wake up on its own when the watcher exits; output only appears after an explicit poll. A command-response injection mechanism would remove the need for tmux-driven key injection and make event-driven orchestration much cleaner.
7 Comments
Additional environment details from the repro run:
The key behavior observed was that a background watcher could complete, but the active Codex session did not receive a spontaneous wake-up or injected turn; I had to explicitly poll the running session to observe the output.
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Not a Duplicate.
@etraut-openai Will this be worked on?
I ran into the same need while testing file/channel-watch workflows where a background command blocks on an event source and should wake Codex when it emits output.
I put together a discussion branch with one concrete implementation sketch:
https://github.com/fl4p/codex/tree/feat/wake-on-background-output
High-level behavior in the branch:
wake_on_outputboolean to unifiedexec_command.exec_commandtool call has yielded is batched and delivered as a bounded synthetic user message.Local validation on that 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_specpassedI also opened #29865 before finding this issue; I’m closing that one as a duplicate and leaving the patch link/details here instead.
I ran into this same gap and ended up building the tool-shaped version of it, so sharing here since this looks like where it's converging.
Instead of a flag on
exec_command(#29865) or a generic injection path, I added an agent-callablemonitortool: the model runs a shell command as a background watcher withaction=start/stop/list, and each line it prints (stdout or stderr) wakes the idle session and starts a turn. While the watch is quiet the session makes no API calls. It is the same core seam everyone in this thread is describing: background output delivered as a bounded, untrusted synthetic user message through the session's existing idle-start path, only when the session can take it. No protocol change, and the watcher is just a normal sandboxedunified_execprocess, so it inherits the existing approval/sandbox/shell handling.The difference from the flag form is that it is a tool the model reaches for and drops mid-task (named, ephemeral watches it manages via a small per-session registry), rather than a property of one exec call.
I have a working reference and I have been running it live in my own Codex, both the CLI and the Desktop app. It is feature-gated, off by default. Full diff, one commit on the v0.142.0 tag: https://github.com/openai/codex/compare/rust-v0.142.0...yaanfpv:codex:monitor-tool. It carries tests (eight integration plus two unit, clean under fmt and clippy) and a few output-safety bounds (line and byte flood guards, and no silently dropped notifications).
I wrote the full design up as #29922. Happy to fold it in here if this is the better home, and glad to open a PR if the approach is useful.
+1