Skip to content

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

Description

@ramsey-coding

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 writes the complete merged trajectory (actions, observations, final output) as a JSON array to 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions