Feature request: --session-id flag to set session UUID at launch
Summary
codex supports resume <uuid> to resume a specific session. However, there is no way to set the session UUID at launch time (analogous to Claude Code's --session-id <uuid>).
Use Case
I'm building TUICommander (https://github.com/stefanospin/tuicommander), a terminal orchestrator that manages multiple AI agent sessions across branches and worktrees. When the user switches branches, we persist terminal state and later restore it with the correct session.
Current workaround: After launching codex, scan ~/.codex/sessions/ for the newest JSONL file and extract the UUID from its filename. This couples us to undocumented filesystem layout.
With --session-id: We generate a UUID before launch, pass codex --session-id <uuid>, and save it. On restore: codex resume <uuid>. Clean, deterministic, no filesystem scraping.
Proposed API
codex --session-id <uuid> # Start a new session with this UUID
codex resume <uuid> # Resume that session later (already works)
This is exactly what Claude Code implements with claude --session-id <uuid> + claude --resume <uuid>.
Alternatives Considered
- Filesystem scraping of ~/.codex/sessions/: works but undocumented, may break
- Interactive picker via codex resume: not scriptable
3 Comments
+1 on this. We're building an agent orchestration console that manages sessions across multiple CLI agents (Claude Code, Cursor Agent, Codex). Both Claude Code (
--session-id) and Cursor Agent (--resumewhich creates if not exists) support specifying the session ID upfront for new runs.With Codex, we have to start the process first, then parse the output to discover the session ID after the fact, and backfill it into our database. This creates a race window where the session is "unknown" and complicates the orchestration logic significantly compared to the other agents.
A
--session-idflag oncodex execwould let us pre-register sessions, correlate logs immediately, and use the same ID for both new and resumed runs without special-casing Codex.(Closed our duplicate #15271 in favor of this issue.)
Is this a duplicate of #7801 ?
Actually yes.