Bug Description
codex exec --json hangs indefinitely when the --image flag is used. The CLI successfully initializes (thread.started event is emitted) but then never processes the request or emits any further events.
Environment
- Codex CLI Version: 0.50.0
- Platform: macOS (Darwin 25.0.0)
- Installation: npm global install (
npm i -g @openai/codex)
Minimal Reproduction
# Create or use any test image
echo "Describe what you see in this image" | codex exec --json --image /path/to/any/image.png
Expected behavior:
- Codex should process the image and prompt
- Stream events like
item.*, agent_message_delta, agent_message, etc.
- Eventually emit
turn.completed or task_complete
Actual behavior:
- Emits
{"type":"thread.started","thread_id":"..."}
- Hangs indefinitely - no further output
- Never completes, must be killed manually
Without Images: Works Fine
echo "Write a hello world script" | codex exec --json --cd /tmp
This works perfectly and streams all expected events (item.completed, agent_message, etc.).
Additional Context
- The bug exists in both 0.49.0 and 0.50.0
- The hang occurs after initialization, suggesting a state machine bug in the event loop
- The TypeScript SDK (
@openai/codex-sdk) is also affected since it uses --image flags internally
- No errors are emitted to stderr
- The process doesn't crash; it just stops producing output
Workaround
Currently using a timeout mechanism to detect the hang:
try:
line = await asyncio.wait_for(
process.stdout.readline(), timeout=90
)
except asyncio.TimeoutError:
# Kill and report error
process.kill()
Impact
This makes image-based workflows completely unusable in non-interactive mode, which is critical for CI/CD pipelines and programmatic integrations.
Related Issues
This may be related to:
Bug Description
codex exec --jsonhangs indefinitely when the--imageflag is used. The CLI successfully initializes (thread.startedevent is emitted) but then never processes the request or emits any further events.Environment
npm i -g @openai/codex)Minimal Reproduction
Expected behavior:
item.*,agent_message_delta,agent_message, etc.turn.completedortask_completeActual behavior:
{"type":"thread.started","thread_id":"..."}Without Images: Works Fine
This works perfectly and streams all expected events (
item.completed,agent_message, etc.).Additional Context
@openai/codex-sdk) is also affected since it uses--imageflags internallyWorkaround
Currently using a timeout mechanism to detect the hang:
Impact
This makes image-based workflows completely unusable in non-interactive mode, which is critical for CI/CD pipelines and programmatic integrations.
Related Issues
This may be related to: