Eight Ways codex exec --json Silently Lies to You
Eight Ways codex exec --json Silently Lies to You
If you are scripting headless Codex sessions — piping codex exec --json into a log pipeline, driving multi-agent orchestration, or building a CI gate that reads structured output — eight bugs filed on 29 November 2026 in a tight two-hour window mean the JSON stream you are reading is quietly incomplete, inaccurate, or misrepresenting what the agent actually did.
None of them surface an error. The command exits zero. The JSON is well-formed. You just cannot trust what it says.
This article documents each failure mode (GitHub issue number, description, impact) and the workaround available today.
Background: What codex exec --json Is For
codex exec --json runs a non-interactive Codex turn and emits a newline-delimited stream of JSON objects representing every agent event: tool calls, shell commands, model output, spawned sub-agents, errors, and coordination messages. The intent is to make Codex scriptable — a building block for pipelines, audit trails, and orchestrators that need machine-readable output rather than a TUI.
The bugs below were filed in a batch on 29 November 2026, suggesting systematic testing of this interface. They span signal handling, tool-definition leakage, event state management, silent message drops, error serialisation, schema mismatches, and stream ordering. Together they reveal that the JSON output API has accrued significant correctness debt.
The Eight Failures
1. Signal termination loses its identity (#64525)
What happens: When a PTY command (exec_command) is killed by a Unix signal (SIGTERM, SIGKILL, SIGSEGV, etc.), the JSON output reports exit code 128 + signal_number — a bare integer — rather than preserving the signal name or number separately.
Why it matters: Downstream tooling that needs to distinguish “process killed by SIGKILL” from “process exited 137” (which is what 128+9 looks like) cannot do so. Crash triage, audit trails, and restart policies that key on signal identity silently receive wrong information.
Workaround: Cross-reference the raw exit code against the 128+ offset convention manually (signal = exit_code - 128 for codes above 128). No clean fix is available until the event schema is updated to include a separate signal field.
2. request_user_input appears in tool definitions even when unavailable (#64530)
What happens: The JSON stream’s tool-definition section lists request_user_input as an available tool even in Desktop sessions where the tool is not reachable (the UI does not surface it, and calls to it fail silently).
Why it matters: An orchestrator that inspects the tool list to decide whether to send a prompt expecting user input will conclude the tool is available and schedule an interaction that never completes. The agent blocks or times out with no meaningful error.
Workaround: Do not rely on the tool-definition section to determine runtime availability of request_user_input. Treat it as unavailable in all Desktop sessions until a fix ships.
3. unified_exec command_execution items stay in_progress forever (#64531)
What happens: When a unified_exec command yields a command_execution item, that item’s status is set to in_progress and is never updated to completed or failed in the JSON stream — even after the command finishes.
Why it matters: Any pipeline that waits for a command_execution item to leave in_progress before proceeding will hang indefinitely. Log collectors that derive execution duration from state transitions will show commands as permanently running.
Workaround: Do not use the in_progress → terminal-state transition of command_execution items as a synchronisation gate. Use the parent unified_exec completion event instead, or apply a timeout.
4. Multi-agent coordination messages are silently dropped (#64533)
What happens: codex exec --json drops four categories of items entirely from the output stream: SendMessage, FollowupTask, InterruptAgent, and ListAgents. These are the coordination primitives used by multi-agent Codex sessions to communicate between agents and orchestrators.
Why it matters: This is the highest-impact bug in the batch. An orchestrator consuming the JSON stream of a multi-agent session receives no visibility into inter-agent messages, follow-up task scheduling, interruptions, or agent enumeration. The session appears to run silently with no coordination activity — a complete blind spot.
Workaround: There is no workaround today that recovers the dropped items from the stream. If your use case depends on observing multi-agent coordination events, avoid codex exec --json for orchestrated sessions until this is fixed.
5. AgentLimitReached errors omit max_threads (#64537)
What happens: When the agent limit is reached, CodexErrorDetails::AgentLimitReached serialises to JSON but drops the max_threads field from the output. The error message in the stream says the limit was reached without saying what the limit is.
Why it matters: Orchestration logic that needs to adjust concurrency based on the reported limit cannot do so. Operators reading logs cannot distinguish “limit is 4, you hit it” from “limit is 32, something went wrong”.
Workaround: The max_threads value can be inferred from your ~/.codex/config.toml max_agent_threads setting (or the CLI default of 4). Log it at session start rather than relying on the error event.
6. CollabToolCallItem failure details are omitted (#64538)
What happens: When a CollabToolCallItem completes with status: failed, the JSON output omits the error details. The status field is present; the reason for failure is not.
Why it matters: Collaborative tool calls are used in multi-model sessions where one agent invokes tools on behalf of another. When they fail, the only record of why is in the error details — which are now silent. Debugging failed collaborative sessions from logs is impossible.
Workaround: None available from the JSON stream. Enable verbose logging in ~/.codex/config.toml (log_level = "debug") and cross-reference the stderr log for the failure reason.
7. spawn_agent v2 schema mismatch: task_name vs name (#64539)
What happens: The spawn_agent v2 API exposes a parameter named task_name in its JSON schema. When validation fails, the error message refers to a field called name — a field that does not exist in the schema. The parameter name in the spec and the parameter name in the error message are different.
Why it matters: Developers who write orchestration code that programmatically constructs spawn_agent calls and hit validation errors receive a message pointing them to a field that does not exist in the schema. This is a debugging dead end.
Workaround: Ignore the name reference in the error message. The correct field name is task_name. The issue is a documentation/error-string mismatch; the runtime accepts task_name correctly.
8. Pre-stream output is never delivered as outputDelta (#64542)
What happens: In unified exec mode, any output that a command prints before the streaming session fully initialises is not delivered as outputDelta events in the JSON stream. It is emitted to the terminal but silently discarded from the structured output.
Why it matters: Tools that print version banners, startup diagnostics, or early progress before they enter their main loop will have that output invisible to any consumer of the JSON stream. CI pipelines that check for startup strings or parse tool preamble will miss them entirely.
Workaround: Where possible, restructure invoked tools to emit significant output after a brief startup delay, or capture stderr separately via a wrapper script. There is no way to recover the pre-stream output from the JSON API in the current build.
Common Thread
All eight bugs were filed in a two-hour window, which suggests a single developer or team systematically exercising the codex exec --json interface against a checklist. The failures span every layer of the JSON output pipeline: event schema, state machine, serialisation, message routing, and stream ordering. The implication is that the interface has been shipping but not deeply tested under programmatic use.
The most dangerous failures for production use are #64533 (silent message drops for multi-agent coordination) and #64531 (commands stuck in in_progress). Both affect orchestration correctness in ways that are hard to detect without independent verification.
What to Do Now
If you are running codex exec --json in production today:
- Audit your use of multi-agent coordination — if your sessions spawn sub-agents or send inter-agent messages, those events are invisible in the JSON stream (#64533). Add independent health checks.
- Never gate on
command_executionstate transitions — use the parent completion event or a timeout (#64531). - Treat the tool-definition section as advisory only — do not use it to determine which tools are actually callable (#64530).
- Log
max_threadsat session start — do not rely onAgentLimitReachedto tell you the limit (#64537). - Cross-reference debug logs for collaborative tool failures — the JSON stream will not tell you why they failed (#64538).
Watch the openai/codex issue tracker for fixes — given the systematic nature of the batch, a targeted patch release addressing these is plausible within the v0.172.x or v0.174.0 cycle.