Skip to content

Support waking Codex on background exec_command output #29865

Closed as not planned
Closed as not planned

Description

@fl4p

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_command behavior unchanged by default.
  • Add wake_on_output: true for explicit monitor/watch commands.
  • After the initial exec_command call 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_output to the unified exec_command tool schema and request path.
  • Starts a background output waker only when the flag is true.
  • Ignores output while the initial exec_command tool 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 fmt passed
  • just fix -p codex-core passed
  • just test -p codex-core wake_on_output passed
  • just test -p codex-core background_output_wake passed
  • just test -p codex-core shell_spec passed

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

  1. added
    enhancementNew feature or request
    CLIIssues related to the Codex CLI
    tool-callsIssues related to tool calling
    on Jun 24, 2026
  2. github-actions commented on Jun 24, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. fl4p commented on Jun 24, 2026

    @fl4p
    Author

    Closing as a duplicate of #22003. I added the patch branch and validation details there: #22003 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLIenhancementNew feature or requesttool-callsIssues related to tool calling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions