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.

View original on GitHub ↗

3 Comments

etraut-openai contributor · 10 months ago

We've added the session ID to the /status output. This is the recommended way to retrieve the current session ID.

etraut-openai contributor · 10 months ago

I just realized that you were talking specifically about non-interactive mode, so /status wouldn't apply in that case. Reopening.

etraut-openai contributor · 6 months ago

This was added a while ago, we just forgot to close this issue.

codex exec --json now emits a first JSONL event of type thread.started. That event includes the thread ID.