Repository navigation
Description
Version / Commit
- Observed in:
codex-cli 0.172.0(codex exec --json) - Verified on
main(065e18b)
Summary
When a shell command launched via unified_exec (exec_command) exceeds yield_time_ms and yields a live background PTY session back to the model, codex exec --json emits an item.started event for the command_execution with status: "in_progress", aggregated_output: "", and exit_code: null — and never emits an item.updated or item.completed event for that item if the model does not wait for the process to exit before the turn/session finishes.
As a result, headless --json consumers (CI runners, IDE integrations, trajectory evaluators) lose both the partial stdout that was already returned to the model and the fact that the command yielded/timed out.
Source Location (main @ 065e18b)
- Deferred completion on yielded PTY —
codex-rs/core/src/unified_exec/process_manager.rs:785-828andcodex-rs/core/src/unified_exec/async_watcher.rs:175-220:
When the process has not exited withinyield_time_ms,emit_exec_end_for_unified_execis deferred to the backgroundasync_watchertask until the child exits. - JSONL event processor —
codex-rs/exec/src/event_processor_with_jsonl_output.rs:163-183:
command_executionitems are only serialized to stdout onItemStartedandItemCompleted. Partial output already delivered to the model on yield is not emitted as anitem.updatedevent, and still-running items are not finalized whenturn.completed/ session shutdown occurs before the child exits.
Reproduction
- Run
codex exec --jsonwith a prompt that executes a long-running command printing an initial line before sleeping, e.g.:and instructs the agent not to poll/wait further if the initial observation yields with a live session ID.bash -c "echo '[MIG-502] phase backfill started'; sleep 400" - Inspect the JSONL stdout stream:
{"type":"item.started","item":{"id":"item_10","type":"command_execution","command":"...","aggregated_output":"","exit_code":null,"status":"in_progress"}} - The model receives the partial stdout and live session ID, proceeds to subsequent items (
item_11,item_12, ...), and completes the turn — yetitem_10never receives anyitem.updatedoritem.completedevent anywhere in the JSONL stream.
(Reproduced during TraceTrial-Bench Core-95 evaluation on E3-longrun-timeout-002 with [email protected].)
Expected Behavior
In codex exec --json:
- Emit an
item.updatedevent containing the partialaggregated_outputcaptured up toyield_time_mswhen aunified_execcommand yields to the model, and/or - Flush and finalize any still-running
command_executionitems with their accumulated output beforeturn.completed/ process exit so noitem.startedis orphaned in the JSONL stream.
Activity