codex exec exits 0 after partial built-in image generation; requested workspace artifacts are missing
What version of Codex CLI is running?
codex-cli 0.147.0
What subscription do you have?
ChatGPT Pro via OAuth (stored auth mode: chatgpt)
Which model were you using?
gpt-5.6-sol
What platform is your computer?
macOS 26.6 (25G72), Apple Silicon arm64
What terminal emulator and version are you using (if applicable)?
Non-interactive codex exec, launched as a subprocess with no TTY.
Codex doctor report
Relevant redacted fields from codex doctor --json immediately after reproduction:
{
"overallStatus": "warning",
"codexVersion": "0.147.0",
"auth.credentials": {
"status": "ok",
"stored API key": "false",
"stored ChatGPT tokens": "true",
"stored auth mode": "chatgpt"
},
"config.load": {
"status": "ok",
"model": "gpt-5.6-sol",
"model provider": "openai",
"image_generation": "enabled"
},
"network.provider_reachability": {
"status": "ok",
"summary": "active provider endpoints are reachable over HTTP"
},
"network.websocket_reachability": {
"status": "ok",
"handshake result": "HTTP 101 Switching Protocols"
},
"runtime.provenance": {
"status": "ok",
"platform": "macos-aarch64",
"version": "0.147.0"
}
}
What issue are you seeing?
A non-interactive codex exec task using ChatGPT/OAuth and the built-in image-generation tool was explicitly instructed to:
- generate exactly six separate bitmap images;
- save them to six exact workspace paths;
- visually inspect all six;
- confirm all six files exist before finishing.
The run generated only two images under $CODEX_HOME/generated_images/<run-id>/, copied none to the requested workspace paths, then exited with status 0.
Observed after exit:
workspace_targets_present 0 of 6
default_outputs_present 2
shell_exit_status 0
The final output included:
The references establish ... I’m starting the six independent generations now ...
The first cargo-bay result ... I’m holding it provisionally ...
ERROR codex_models_manager::manager: failed to refresh available models: timeout waiting for child process to exit
There was no explicit error saying that four image calls had not run, that the requested files were missing, or that verification had failed. An automation caller therefore receives a successful process exit for a materially incomplete image-generation task.
I found #23119 and #34397 for the same codex_models_manager timeout string. This report is distinct: the CLI did not hang and did not merely emit noisy stderr; it terminated successfully after partial image generation, with the required workspace artifacts absent.
No OAuth URLs, tokens, API keys, prompts containing private story text, or generated images are attached.
What steps can reproduce the bug?
- Authenticate Codex through ChatGPT OAuth (not
OPENAI_API_KEY). - Enable the built-in
image_generationfeature. - In a writable empty directory, create
image-task.md:
Generate exactly six separate bitmap illustrations with the built-in image generation tool.
Save them as:
- images/01.png
- images/02.png
- images/03.png
- images/04.png
- images/05.png
- images/06.png
Generate each asset separately. Before finishing, inspect every output and verify all six exact paths exist. If any image call fails or any path is missing, report failure rather than success.
- Run:
python3 -c 'print(open("image-task.md", encoding="utf-8").read())' \
| codex exec --ignore-user-config --ephemeral --skip-git-repo-check -s workspace-write -
echo $?
- Inspect both
images/and$CODEX_HOME/generated_images/.
In the observed run, two default-location PNGs existed, zero requested workspace files existed, and the shell status was 0.
This may be timing-sensitive. The two image results arrived slowly, and the codex_models_manager child-process timeout appeared near termination.
What is the expected behavior?
At least one of the following:
codex execcontinues until the explicitly required image calls and path checks finish;- if the built-in image tool or an internal child process prevents completion,
codex execexits non-zero with a clear error; - a final tool/task status explicitly marks the run incomplete so automation does not treat exit 0 as delivery success.
A background model-catalog refresh failure should not silently convert an unfinished multi-image task into a successful CLI exit.
Additional information
- Duplicate search performed for
generated_images partial,image_generation exit 0, andbuilt-in image codex exec; no matching issue was found. - Related but not duplicate: #23119 and #34397.
- The generated files themselves were valid PNGs; the problem is partial execution, missing requested copies, missing verification, and success exit semantics.
2 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Two code-level facts explain the clean exit-0 after a partial job.
First, built-in image generation failures are deliberately non-fatal: every error path in the tool — including usage/rate limits, which are specially detected — is returned to the model as a tool-call error string (
RespondToModel), never escalated to the process (https://github.com/openai/codex/blob/1f41cc5d92/codex-rs/ext/image-generation/src/tool.rs#L163-L198, limit detection at#L250-L260). So after two successes, calls 3–6 most likely failed (rate/usage limit on a burst of generations), the model received the error text, and simply wrapped up without copying anything to your workspace paths.Second,
codex exec's exit code reflects protocol health, not task outcome: it exits non-zero only on fatal stream/session errors. A turn that completes normally — even one where every tool call inside it failed — is exit 0. Thecodex_models_managerrefresh timeout is unrelated background noise (same string as #23119/#34397).Fix outline: (1) count failed tool calls per turn and surface them in exec's human/JSONL output summary; (2) offer an opt-in flag mapping any failed-tool-call turn to a non-zero exit; (3) emit image-generation failures as explicit stderr lines, not only model-visible text.