Skip to content

Bug: codex exec --json leaves yielded unified_exec command_execution items permanently in_progress with empty aggregated_output #64531

Backlog

Description

@zsicheng0214

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)

  1. Deferred completion on yielded PTY — codex-rs/core/src/unified_exec/process_manager.rs:785-828 and codex-rs/core/src/unified_exec/async_watcher.rs:175-220:
    When the process has not exited within yield_time_ms, emit_exec_end_for_unified_exec is deferred to the background async_watcher task until the child exits.
  2. JSONL event processor — codex-rs/exec/src/event_processor_with_jsonl_output.rs:163-183:
    command_execution items are only serialized to stdout on ItemStarted and ItemCompleted. Partial output already delivered to the model on yield is not emitted as an item.updated event, and still-running items are not finalized when turn.completed / session shutdown occurs before the child exits.

Reproduction

  1. Run codex exec --json with a prompt that executes a long-running command printing an initial line before sleeping, e.g.:
    bash -c "echo '[MIG-502] phase backfill started'; sleep 400"
    and instructs the agent not to poll/wait further if the initial observation yields with a live session ID.
  2. Inspect the JSONL stdout stream:
    {"type":"item.started","item":{"id":"item_10","type":"command_execution","command":"...","aggregated_output":"","exit_code":null,"status":"in_progress"}}
  3. The model receives the partial stdout and live session ID, proceeds to subsequent items (item_11, item_12, ...), and completes the turn — yet item_10 never receives any item.updated or item.completed event 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:

  1. Emit an item.updated event containing the partial aggregated_output captured up to yield_time_ms when a unified_exec command yields to the model, and/or
  2. Flush and finalize any still-running command_execution items with their accumulated output before turn.completed / process exit so no item.started is orphaned in the JSONL stream.

Activity

  1. added
    bug
    CLI
    exec
    tool-calls
    on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIbugexectool-calls

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions