Skip to main content

Module backend_codex

Module backend_codex 

Source
Expand description

Codex agent backend: drives codex exec --json headless.

Ground truth is crates/engine/tests/fixtures/codex_exec_scrutiny.jsonl, a recorded codex exec --json transcript. This module is single-shot only: unlike backend_claude, there is no --resume and no streaming-input mode, so CodexSession::send_user_message and a resumed SessionSpec are both rejected at the seam rather than translated into codex flags.

Several SessionSpec fields are claude-isms with no codex equivalent and are deliberately ignored when building argv: json_schema, max_budget_usd, resume, permission_mode, allowed_tools / disallowed_tools, tools, settings_json, effort.

Structs§

CodexBackend
The AgentBackend for codex exec --json: single-shot with sandbox mode selected from the session role.
CodexSession
A live codex exec --json session (the AgentSession impl).
CodexStreamParser
Stateful wrapper around parse_codex_line that remembers the most recent agent_message AgentEvent::Text and stitches it into the terminal AgentEvent::Result when a turn.completed line arrives.

Functions§

build_args
Build the argv (excluding the binary itself) for one session.
discover_codex_binary
Locate a working codex binary.
parse_codex_line
Parse one stdout line into zero or more AgentEvents. model is the configured model, used both as the Init fallback (codex’s thread.started carries no model field in observed output) and as the pricing key when a terminal event has no CLI-reported dollar cost.
parse_codex_value
Map one parsed codex exec --json value to events (see module docs / fixture).