feat: session persistence

Resolved 💬 5 comments Opened Apr 16, 2025 by yuan-alex Closed Aug 7, 2025
💡 Likely answer: A maintainer (tibo-openai, collaborator) responded on this thread — see the highlighted reply below.

Allow the user to continue a previously saved session/thread with the same current working directory by using a command like /session. This command can only be used before any message has been sent.

Incremental thread state is already persisted in ~/.codex/sessions/rollout-*.json but an alternative structure is necessary to store thread information.

A simple alternative could allow the user to continue the most recently saved thread state for the current working directory.

View original on GitHub ↗

5 Comments

tibo-openai collaborator · 1 year ago

Could you expand on

an alternative structure is necessary to store thread information

?

igor-gorohovsky · 1 year ago

I agree, I really miss the feature to return to the old session

scottleibrand contributor · 1 year ago

https://github.com/openai/codex/discussions/341 is also asking for this, and has some good design ideas.
https://github.com/openai/codex/issues/118 as well.

yuan-alex · 1 year ago

The existing rollout files store the entire thread state at each generation step. The session.id field of each rollout is a randomly generated UUID. There is no explicit or reliable index of what threads exist or how they're related to a specific project. A new thread structure will help map project directories to rollouts so we can easily restore the latest rollout.

~/.codex/threads.json

[
  {
    "id": "thread_id",
    "cwd": "/path/to/project",
    "created_at": "2025-04-18T10:32:00Z",
    "updated_at": "2025-04-18T11:12:00Z",
    "first_prompt": "explain this codebase to me",
    "summary": "Codex Codebase Summary",
    "latest_rollout": "rollout-*.json"
  }
]
codex-maintainers · 1 year ago

Thanks for the feedback! Please try the latest version of Codex CLI to see if this issue persists. If it does, we'd appreciate any further details or contributions to the codex-rs/ implementation.