Skip to content

fix(model): send the codex_exec prompt over stdin - #491

Open
ni (nniiovoo) wants to merge 1 commit into
microsoft:mainfrom
nniiovoo:fix/codex-exec-stdin
Open

ni (nniiovoo) wants to merge 1 commit into
microsoft:mainfrom
nniiovoo:fix/codex-exec-stdin

Conversation

@nniiovoo

Copy link
Copy Markdown
Contributor

Fixes #490

The codex_exec target passed the prompt as an argument and left stdin inherited. With a prompt argument and a piped stdin, codex exec also reads stdin and appends it as a <stdin> block. So a run started from a pipe (the Copilot MCP plugin, ssh host cmd, docker run -i) either hung until exec_timeout, or sent whatever arrived on that pipe to the model.

The harness now ends the command with - and passes input=prompt (UTF-8, errors="replace"), the same as codex_backend and the sleep backend since #205. That also avoids the Windows codex.CMD shim cutting a multi-line argument (#197). The -i image flags still come before --output-last-message, so - stays the prompt.

Tests: one test added to tests/test_codex_cli_prompt_stdin.py, next to the other two Codex call sites, using the same helper. It fails on main (no input, prompt in argv).

I also checked with a stand-in codex that follows the documented stdin rule, with the parent's stdin as a pipe. Before the change the rollout hung on an idle pipe, and a message written to the pipe ended up in the prompt. After it, both cases return at once with the clean prompt. No model calls.

Full suite on macOS: 2632 passed. The 2 failures in tests/test_sleep_adopt_skill_subset.py also fail on main.

The codex_exec target passed the prompt as an argument and left stdin
inherited. With a prompt argument and a piped stdin, `codex exec` also
reads stdin and appends it, so a run started from a pipe (the Copilot
MCP plugin, `ssh host cmd`, `docker run -i`) hung until exec_timeout,
or sent whatever arrived on that pipe to the model.

The harness now ends the command with "-" and passes input=prompt, as
codex_backend and the SkillOpt-Sleep backend do (microsoft#205).

Fixes microsoft#490

Signed-off-by: NNIIOVO <haimingni44@gmail.com>

This branch has not been deployed

No deployments
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.

codex_exec target rollouts read the trainer's stdin and hang or add it to the prompt

1 participant