codex exec --image swallows the positional prompt → "No prompt provided via stdin"
Open 💬 2 comments Opened Jun 25, 2026 by andrew-stelmach-fleet
What
codex exec --image <file> "<prompt>" exits with No prompt provided via stdin even though a prompt was passed.
Repro (codex-cli 0.142.0)
codex exec --image screenshot.png "describe this image"
# Reading prompt from stdin...
# No prompt provided via stdin. (exit 1)
Why
The shared --image flag (codex-rs/utils/cli/src/shared_options.rs) is declared num_args = 1.. (greedy), so it consumes the trailing positional [PROMPT] as another image path. With no positional prompt left, Codex falls back to (empty) stdin and exits.
The resume subcommand's image arg already uses num_args = 1 and is unaffected, so the bug only hits the fresh top-level codex exec path.
Proposed fix
Set num_args = 1 on the shared arg (consistent with resume). Comma (--image a,b) and repeated (-i a -i b) forms still work; only the undocumented space-separated form is dropped (now a clear parse error). Happy to PR — branch ready.
2 Comments
I pushed a focused fix for this here:
https://github.com/openai/codex/compare/main...Nicolas0315:codex:codex/exec-image-single-arg?expand=1
What changed:
--image/-ioption from a greedynum_args = 1..to one value per flag, while preserving comma-delimited values via the existingvalue_delimiter = ','.codex-execparser coverage for--image screenshot.png "describe this image"so the positional prompt is retained.codex execparser test.Verification:
just fmt,git diff --check,cargo test --manifest-path codex-rs\Cargo.toml -p codex-exec exec_image, exactcodex-execparser tests, scoped top-levelcargo test --manifest-path codex-rs\Cargo.toml -p codex-cli --bin codex exec_image_preserves_prompt_at_top_level, andcargo check --manifest-path codex-rs\Cargo.toml -p codex-exec -p codex-cliall passed.cyberagent-mac-m5maxover SSH: fresh shallow clone, patch apply,git diff --check, exactcodex-execparser tests, and exact top-levelcodexparser test passed. Coldcodex-execbuild/test command tookreal 441.63s; exact tests were used after a broad substring filter reported zero tests on that host.nicolas-macbook-proover SSH: fresh shallow clone, patch apply, andgit diff --checkpassed; cargo/rustc are not installed on that node.rtx5060tiover SSH: fresh shallow clone, patch apply, andgit diff --checkpassed; Rust is present but the node resolves/usr/bin/linkto GNU coreutilslink, matching the known linker misconfiguration, so Rust builds are blocked there.nicolas2025over SSH: fresh shallow clone, patch apply, andgit diff --checkpassed; cargo/rustc paths are zero-byte stubs, so Rust builds are blocked there.Unable to create PR - I can't create PR to repo... Can someone assist?