CLI flag to save trajectory/output as JSON for non-interactive `codex exec` runs

Resolved 💬 3 comments Opened Aug 14, 2025 by ramsey-coding Closed Oct 30, 2025

What feature would you like to see?

Description

Currently, Codex CLI automatically writes per-session JSONL logs under
$CODEX_HOME/sessions/YYYY/MM/DD/rollout-*.jsonl.

This works, but:

  • The output path is buried in the date-sharded sessions/ structure.
  • There is no CLI option to explicitly choose a log file path.
  • For non-interactive runs (codex exec), there is no direct way to capture the complete trajectory and outputs in a JSON file as part of the same command, without post-processing the .jsonl files manually.

Example of current workflow

CODEX_HOME=codex_logs codex exec --full-auto "update CHANGELOG for next release"

Proposed Feature
Add a CLI option to specify a JSON log output path for the current run. For example:

codex exec --full-auto \
  --json-log ./workspace.json \
  "update CHANGELOG for next release"

Where:

--json-log <path> writes the complete merged trajectory (actions, observations, final output) as a JSON array to <path> after the run completes.

Request

Please consider adding --json-log to both interactive and non-interactive (exec) modes, so users can directly capture structured session output without manual post-processing.

Are you interested in implementing this feature?

_No response_

Additional information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗