Session ID in non-interactive prompts
Resolved 💬 3 comments Opened Aug 1, 2025 by alibrahimzada Closed Feb 23, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
It would be nice to include session ID in the first jsonl when running the agent in non-interactive mode, e.g., codex exec --json. Right now its hard to retrieve converstation later from $CODEX_HOME/sessions. Claude code has this feature already.
3 Comments
We've added the session ID to the
/statusoutput. This is the recommended way to retrieve the current session ID.I just realized that you were talking specifically about non-interactive mode, so
/statuswouldn't apply in that case. Reopening.This was added a while ago, we just forgot to close this issue.
codex exec --jsonnow emits a first JSONL event of typethread.started. That event includes the thread ID.