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.

View original on GitHub ↗

2 Comments

Nicolas0315 · 2 months ago

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:

  • Changed the shared --image/-i option from a greedy num_args = 1.. to one value per flag, while preserving comma-delimited values via the existing value_delimiter = ','.
  • Added codex-exec parser coverage for --image screenshot.png "describe this image" so the positional prompt is retained.
  • Added repeated/comma-delimited image coverage and a top-level codex exec parser test.

Verification:

  • Local Windows/MSVC: just fmt, git diff --check, cargo test --manifest-path codex-rs\Cargo.toml -p codex-exec exec_image, exact codex-exec parser tests, scoped top-level cargo test --manifest-path codex-rs\Cargo.toml -p codex-cli --bin codex exec_image_preserves_prompt_at_top_level, and cargo check --manifest-path codex-rs\Cargo.toml -p codex-exec -p codex-cli all passed.
  • cyberagent-mac-m5max over SSH: fresh shallow clone, patch apply, git diff --check, exact codex-exec parser tests, and exact top-level codex parser test passed. Cold codex-exec build/test command took real 441.63s; exact tests were used after a broad substring filter reported zero tests on that host.
  • nicolas-macbook-pro over SSH: fresh shallow clone, patch apply, and git diff --check passed; cargo/rustc are not installed on that node.
  • rtx5060ti over SSH: fresh shallow clone, patch apply, and git diff --check passed; Rust is present but the node resolves /usr/bin/link to GNU coreutils link, matching the known linker misconfiguration, so Rust builds are blocked there.
  • nicolas2025 over SSH: fresh shallow clone, patch apply, and git diff --check passed; cargo/rustc paths are zero-byte stubs, so Rust builds are blocked there.
chethanuk · 1 month ago

Unable to create PR - I can't create PR to repo... Can someone assist?