rollout file not written until first API turn completes, no way to get thread_id at spawn time for embedding tools

Resolved 💬 2 comments Opened Apr 20, 2026 by nmhjklnm Closed Apr 20, 2026

Problem

External tools that spawn Codex sessions (e.g., task runners, mission managers) need to correlate their own session identifiers with Codex thread IDs at spawn time.

Currently the rollout file under ~/.codex/sessions/ is not written until the first API turn completes (~15–30s after startup). There is no earlier signal available to the host process.

Reproduction (exec mode)

# thread.started appears immediately in stdout — thread_id is here
codex exec --json "hello" &

# but the rollout file does NOT appear until ~16s later (after API responds)
ls ~/.codex/sessions/$(date +%Y/%m/%d)/

What we tried

  • Kill before first turn → no rollout file, session not resumable
  • /status slash command → local only, does not trigger file write
  • Watch ~/.codex/sessions/ → file appears only after first API response

Requested

Either of:

  1. Write session_meta to rollout file at session init (before first API call)
  2. Or: support --session-id <UUID> flag so embedders can assign the ID themselves (related: #15767)

Related

  • #15767 custom session ID via ThreadStartParams
  • #8923 expose session ID as env var
  • #15870 rollout not persisted on early transport failure

View original on GitHub ↗

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