Skip to content

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

Closed as not planned

Description

@nmhjklnm

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: Support custom session ID for new threads via ThreadStartParams #15767)

Related

Activity

  1. added
    bugSomething isn't working
    CLIIssues related to the Codex CLI
    sessionIssues involving session (thread) management, resuming, forking, naming, archiving
    execIssues related to the `codex exec` subcommand
    on Apr 20, 2026
  2. etraut-openai commented on Apr 20, 2026

    @etraut-openai
    Contributor

    This behavior is by design, not a bug. You need to complete the first turn before the rollout file is written.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLIbugSomething isn't workingexecIssues related to the `codex exec` subcommandsessionIssues involving session (thread) management, resuming, forking, naming, archiving

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions