[FEATURE] Structured session metrics in codex exec output (tokens, cost, outcome)

Resolved 💬 2 comments Opened Apr 19, 2026 by jerrythomas Closed Apr 21, 2026

Summary

codex exec enables headless execution — great for CI and automation. However the output doesn't include structured session metrics (token counts, cost, outcome, turn count). This blocks building analytics dashboards and automated benchmarks that compare different configurations.

What's needed

Structured JSON output from codex exec that includes:

{
  "session_id": "...",
  "outcome": "completed",
  "turns": 8,
  "tokens_in": 24000,
  "tokens_out": 8000,
  "cost_usd": 0.35,
  "duration_seconds": 45,
  "files_modified": ["src/parser.rs"],
  "tools_used": ["shell", "file_read", "file_write"],
  "sandbox_id": "..."
}

Use case

  • Benchmark: "Does adding context X improve success rate?" — run same tasks, compare metrics
  • CI: fail builds if token cost exceeds budget or success rate drops
  • Dashboard: track per-task cost and efficiency over time

Related

  • #10233 — Non-interactive codex status (JSON output)
  • #6432 — codex exec review with structured results

View original on GitHub ↗

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