codex icon indicating copy to clipboard operation
codex copied to clipboard

[Feature Request] Add /resume command to continue after unrecoverable errors without losing context

Open agenticbuddy opened this issue 3 months ago • 15 comments
trafficstars

Problem When Codex CLI hits an unrecoverable error (usage limit, crash, stream loss, etc.), the entire workflow context is lost. In real projects we often run multiple Codex instances in parallel (different tasks/workspaces). After a restart there is no way to know which session to resume, and prior context persists even after a user-issued /clear in the session.

Proposal: /resume with multi-session support

  1. Persistent checkpoints per session

    • Codex stores resumable state on disk (e.g., ~/.config/codex/sessions/<session_id>/), including: • workspace path • model + reasoning settings • brief instruction hash / title • last N steps / actions (enough to safely continue) • timestamps, token usage snapshot, CLI version
  2. Session listing & selection

    • New command: /resume • Shows active/resumable sessions with a short, informative line per sessions of the current workspace: [session_id] <model/effort> <age / last activity> • Optional filters: --model, --since, --status
    • Resume a session: /resume <session_id> • Resumes exactly that session, even if multiple Codex instances exist.
    • Convenience: /resume (no args) → interactive picker if >1 candidate.
  3. Context isolation & integrity

    • Checkpoints are tied to a specific workspace path to avoid cross-contamination.
  4. Respect /clear and explicit cleanup

    • If the user runs /clear inside a session, Codex marks the session state as “cleared” and: • stops reusing its old context for /resume • optionally keeps a minimal audit trail (metadata only) for transparency
    • New command: /resume purge [--all | --older-than=7d] • Hard-deletes stored session data of the current workspace.
  5. Quality-of-life

    • /resume --from-step N → resume from a specific checkpoint step.
    • /resume --amend "…" → amend instructions before continuing.
    • /resume show → detailed view (last steps, warnings, diffs).
    • JSON output flags (e.g., --json) for scripting/CI.
  6. Concurrency & safety

    • Locking to prevent two Codex processes from resuming the same session concurrently.
    • Clear error if a session is in-use by another PID/host, with an override (--force).
  7. Guardrails awareness

    • If the prior stop was caused by a limiter/guardrail, /resume should: • show the reason and next reset ETA if available • optionally delay/resume automatically when the window resets

Benefits

  • No loss of long-running reasoning work (multi-million token context).
  • Works in real-world setups with multiple parallel Codex instances.
  • Predictable cleanup: /clear truly clears, purges are controllable.
  • Safer resumes with workspace integrity checks and explicit selection.

agenticbuddy avatar Aug 08 '25 04:08 agenticbuddy

This is important. Most tools have sessions and without functionality to resume sessions this tool is seriously lacking.

radixs avatar Aug 19 '25 18:08 radixs

@etraut-openai @ae-openai Team, please prioritize this issue.

ifokeev avatar Aug 26 '25 14:08 ifokeev

+1 for this. Essential feature.

jasonwblock avatar Aug 26 '25 22:08 jasonwblock

agreed we need this + native web search to make codex competitive with Claude Code

Mercurial avatar Aug 29 '25 08:08 Mercurial

@Mercurial FYI web search is already available (codex --search)

ImSingee avatar Aug 29 '25 08:08 ImSingee

honestly shocked this hasn't been implemented.

embarrassing for you guys. you are a billion dollar company. please get this out by the end of the week

softclone avatar Sep 03 '25 15:09 softclone

new version 0.5.1 you changed the UI, but the dialogs still are not being picked up from the ./codex/session folder

shame on you

you are a big company with huge budgets, yet you cannot do something elementary

look at Kilocode, not a big company, but they make an amazing coding agent I will stick with Kilocode instead

Image

ermaxinc avatar Sep 03 '25 19:09 ermaxinc

Essential Features I Believe Are Needed:

  1. Ability to reset to a past conversation
  2. Ability to edit a past conversation
  3. Ability to resume a past conversation

Tocktock avatar Sep 04 '25 02:09 Tocktock

Feature Request: Ability to Name Sessions

When many sessions run in parallel, it becomes difficult to quickly identify the right one. Claude’s early experience highlighted this problem, though summaries improved it somewhat:

      Modified     Created        Msgs Git Branch                        Summary
❯ 1.  4m ago       13m ago          74 chore/migrate-legacy-python       Can you help clarify ...
  2.  1h ago       2h ago          129 chore/migrate-legacy-python       Test Runner Environme...

However, summaries are still limited. Allowing users to explicitly name sessions, and/or set a name when starting one, would make managing multiple instances much easier and provide a smoother workflow.

streichsbaer avatar Sep 04 '25 03:09 streichsbaer

FWIW - in the interim you can prompt Codex to find the session file, summarize and continue development where you left off and see how that works until things are updated.

If I ask you to look at the tail of the jsonl files /home/mneilly/.codex/sessions are you able to determine which jsonl file belongs to this workspace?

Short answer: Yes.

How I can determine it

Search logs for this workspace path: /home/mneilly/RustProjects/ThirdParty/... Pick the most recent .jsonl that mentions it (mtime or timestamp in filename). Optionally verify by tailing that file and checking tool calls referencing files under this repo. Result from a quick scan

Latest matching session: /home/mneilly/.codex/sessions/2025/09/03/rollout-2025-09-03T21-19-33-13cd7434-c293-4e24-87d6-e2026997b873.jsonl Also matches: /home/mneilly/.codex/sessions/2025/09/02/rollout-2025-09-02T22-03-46-fda8e9b7-ff4b-4251-885f-dca948f27b98.jsonl If you want, I can pull a concise summary of the latest session’s tail to confirm it’s the one tied to this workspace and extract key decisions.

Followed by:

Ok, see /home/mneilly/.codex/sessions/2025/09/02/rollout-2025-09-02T22-03-46-fda8e9b7-ff4b-4251-885f-dca948f27b98.jsonl for our chat history on this project. Let me know where we stand and then let's proceed.

Here’s where we stand based on the last session and your repo:

Status summary ... What changed (high level)

... Proposed next steps

Pick one direction to proceed: ,,, Tell me which path you want. If you want me to proceed without waiting, I’ll implement 2)...

mneilly avatar Sep 04 '25 04:09 mneilly

Damn, yet another version 0.5.3, still not developed ? I'm curious what the reason is, as its a basic functionality

aleksandar-radev avatar Sep 04 '25 11:09 aleksandar-radev

We will have experimental support in the next release. However, we may iterate on the API shape (slash commands, etc)

Extension support to follow shortly.

https://github.com/openai/codex/pull/3135

gpeal avatar Sep 04 '25 15:09 gpeal

Are you guys using your own extension at all? Tasks history isn't reloaded after re-start (worked a week ago). All tasks conversations are still in C:\Users\USER.codex\sessions, yet plugin isn't loading them anymore. I am paying 200$ a month for this.

flexorx avatar Sep 07 '25 21:09 flexorx

0.30.0 added the start of support for --resume and --continue:

  • https://github.com/openai/codex/releases/tag/rust-v0.30.0
    • https://github.com/openai/codex/pull/3135
    • https://github.com/openai/codex/pull/3185
    • https://github.com/openai/codex/pull/3218

Originally posted by @0xdevalias in https://github.com/openai/codex/issues/2173#issuecomment-3264145154

0xdevalias avatar Sep 07 '25 23:09 0xdevalias

👏 👏 👏 got it in before monday! well done! ty ty

softclone avatar Sep 08 '25 00:09 softclone

Hello team! Same here, failed to load tasks, I think I have lost my prompt and the context!

tubzby avatar Sep 09 '25 09:09 tubzby

How will this issue fix: https://github.com/openai/codex/issues/2911

bqrkhn avatar Sep 09 '25 10:09 bqrkhn

@flexorx of course we do, and want this just as much as you. We, just like you, are also humans with limited hours and are working as quickly as we can to build all of the things you, us, and everybody else want! We could have opted to not release Codex until we built every feature we wanted but we didn't want to do that either.

gpeal avatar Sep 09 '25 17:09 gpeal

I just released 0.5.6 to the VS Code pre-release channel which supports resuming old local conversations and will fully release it laster today if things are looking good.

In case you missed it, you can codex --resume in the CLI as well. Note that the CLI API may change a bit over the next week. If you use it and it stops working, run codex --help and it should point you at the new subcommand/flag.

Thanks for your patience here, everybody.

gpeal avatar Sep 09 '25 17:09 gpeal

If you use it and it stops working, run codex --help and it should point you at the new subcommand/flag.

Presumably if the current version stops working it will be because they rolled out a change and will unhide the help at the same time; but just to save some people the confusion in the interim; the help for --resume is currently hidden (at least up to 0.31.0; haven't checked beyond that) as per:

  • https://github.com/openai/codex/pull/3218

0xdevalias avatar Sep 09 '25 23:09 0xdevalias

@gpeal Thanks a lot, keep up the good work! : )

Although, an issue i found (not important) is that "archive" or "delete" doesn't work on local tasks, saying "Failed to delete task".

aleksandar-radev avatar Sep 10 '25 17:09 aleksandar-radev

In 0.36.0 this seems to be codex resume

NB as opposed to --resume:

error: unexpected argument '--resume' found

  tip: to pass '--resume' as a value, use '-- --resume'

Usage: codex [OPTIONS] [PROMPT]
       codex [OPTIONS] [PROMPT] <COMMAND>

For more information, try '--help'.```

ryanmaclean avatar Sep 16 '25 19:09 ryanmaclean

Neither --resume nor --continue work. codex version v0.36.0. It's not just hidden, it's not available. Missing this feature is critical for me, as sometimes codex has problems with accepting input after the long session in my environment - it basically doesn't accept most of key strokes, only restarting helps. But the session is lost.

Please reopen until it's implemented and available. Otherwise it's misleading and confusing.

dbabokin avatar Sep 16 '25 22:09 dbabokin

Neither --resume nor --continue work. codex version v0.36.0. It's not just hidden, it's not available.

@dbabokin Did you look at the comment above yours that suggests it changed to resume (not --resume) in 0.36.0?

Which is also documented in codex --help:

Codex CLI

..snip..

Commands:
  ..snip..
  resume      Resume a previous interactive session (picker by default; use --last to continue
              the most recent)
  ..snip..

And codex resume --help:

Resume a previous interactive session (picker by default; use --last to continue the most
recent)

Usage: codex resume [OPTIONS] [SESSION_ID] [PROMPT]

Arguments:
  [SESSION_ID]
          Conversation/session id (UUID). When provided, resumes this session. If omitted, use
          --last to pick the most recent recorded session

  [PROMPT]
          Optional user prompt to start the session

..snip..

As well as the release notes:

  • https://github.com/openai/codex/releases/tag/rust-v0.36.0
    • Resuming old sessions
      Resuming old conversations with codex resume (#3537, #3625).

0xdevalias avatar Sep 17 '25 00:09 0xdevalias

@dbabokin Did you look at the comment above yours that suggests it changed to resume (not --resume) in 0.36.0?

I read the thread, but apparently missed this 🤦🏻‍♂️ Looks like I need more sleep :) My apologies. Thanks for implementing this!

dbabokin avatar Sep 17 '25 01:09 dbabokin

Hi @gpeal . On the current version of the extension I can only see chats for the past 2 days despite my log history going back weeks in .codex and, if that folder is only for CLI, there should still be a lot more history for the extension.. Any idea why that is?

smolcompute avatar Sep 20 '25 21:09 smolcompute

Hi @gpeal . On the current version of the extension I can only see chats for the past 2 days despite my log history going back weeks in .codex and, if that folder is only for CLI, there should still be a lot more history for the extension.. Any idea why that is?

Yes they changed the API I think. I think that's because the structures of the logging dirs. I use https://github.com/andylizf/codexer to solve this issue.

andylizf avatar Sep 26 '25 03:09 andylizf

Love that resume command!

One side note here: I had asked the model if there was a list of sessions, but it claimed there was not and I should keep a record of them myself. And then I landed here via Google search...

derwaldgeist avatar Oct 24 '25 15:10 derwaldgeist