codex exec resume and fork silently drop piped stdin when given a prompt

Open Beginner friendly
#60,999 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
cli

Research direction

Start in codex-rs/exec/src/lib.rs: compare resolve_root_prompt with the resolve_prompt calls used by resume and fork, then inspect the relevant CLI help and tests. Add coverage for positional prompts with piped stdin in both commands, keeping the - cases as controls. Done means stdin is preserved or the combination is explicitly rejected or warned about, with tests confirming the behavior.

Written by the indexing model from the issue text.

Description

bug CLI exec session

Summary

When both a positional prompt and piped stdin are supplied, codex exec appends stdin as a <stdin> block, but codex exec resume and codex exec fork silently discard it. All three commands exit successfully, so an automation can continue without the intended context.

Reproduction

Tested on Windows with codex-cli 0.167.0-alpha.4.1 and SDK fixture source at 6bfdc75f0d9e6fae313234f694839866d7c63c39. Configure an isolated CODEX_HOME with the repository's local mock Responses provider in sdk/python/tests/app_server_harness.py; capture its request input:

# Obtain ID from the thread.started event in the first command.
printf ROOT_PIPE_MARKER | codex exec --json --skip-git-repo-check "root question"
printf RESUME_PIPE_MARKER | codex exec --json --skip-git-repo-check resume "$ID" "resume question"
printf FORK_PIPE_MARKER | codex exec --json --skip-git-repo-check fork "$ID" "fork question"
printf STDIN_SENTINEL_MARKER | codex exec --json --skip-git-repo-check resume "$ID" -

The captured last user inputs were, respectively:

root question\n\n<stdin>\nROOT_PIPE_MARKER\n</stdin>
resume question
fork question
STDIN_SENTINEL_MARKER

All four calls exited 0 and used the local mock, not an external model. The main codex exec --help describes appending piped stdin alongside a prompt; the resume and fork help describe - for reading stdin.

Expected / possible fix

Apply the same positional-prompt-plus-stdin behavior to resume and fork, or explicitly reject or warn about the combination so input is not silently lost. The fresh path uses resolve_root_prompt, while resume and fork use resolve_prompt when a prompt is supplied. Add tests for both commands with a positional prompt and piped input, plus the - control.

Workaround: combine the question and context into stdin and pass - as the prompt.

Dominant language
Rust
Stars
135k
Forks
21.4k
Avg merge
1m
Merged PRs (30d)
995

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openai/codex

All issues in openai/codex

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.