Skip to content

Please make "/undo" back #9203

Open
Open

Description

@SunRunAway

What feature would you like to see?

It quite useful when:

  1. codex unintenally deletes some files which is not tracked by git.
  2. codex unintenally modify something when something is not git committed.
    It bites me several times in recent days and I miss the /undo feature each time.

Additional information

No response

Activity

  1. added
    enhancement
    on Jan 14, 2026
  2. added
    CLI
    on Jan 14, 2026
  3. github-actions commented on Jan 14, 2026

    @github-actions
    Contributor
  4. b20lopez commented on Jan 15, 2026

    @b20lopez

    Bro i lost too much progress just because the/undo is gone!!!! :( :( :(
    Please put it back.

  5. embedding-shapes commented on Jan 15, 2026

    @embedding-shapes

    codex unintenally deletes some files which is not tracked by git.

    This happened to me too just these last days, out of nowhere, been using codex since it was available, and never had this happen to me before. Suddenly it wants to "keep the git repository clean" and deletes anything regardless of it existing before starting codex or not, it doesn't seem to realize what side-effects the commands it runs actually have.

    Work around, actually check things into git or keep out of reach from Codex.

    git is the real solution rather than /undo here as well, the sooner you learn it, the faster you'll be able to continue working without waiting for something to come back, which likely won't come back :) Ask codex to help you learn git ;)

  6. marked I used to /undo a lot #9285 as a duplicate of this issue on Jan 15, 2026
  7. marked Put back /undo #9280 as a duplicate of this issue on Jan 15, 2026
  8. TraFriTCR commented on Jan 15, 2026

    @TraFriTCR

    I find this mainly an issue where I'm working on something in a session, fine with the last few changes codex made, then it makes a bad change. If I don't remember to do a stash before the bad change then how am I supposed to revert without loosing all my progress?

  9. b20lopez commented on Jan 16, 2026

    @b20lopez

    I find this mainly an issue where I'm working on something in a session, fine with the last few changes codex made, then it makes a bad change. If I don't remember to do a stash before the bad change then how am I supposed to revert without loosing all my progress?

    Its gone.. asking codex to fix it will make it worse. Im forced to go back to using Claude.
    Google anti Gravity is also a great alternative.

  10. SunRunAway commented on Jan 16, 2026

    @SunRunAway
    Author

    @etraut-openai Could you revert it back? If there is a particular reason to hide it, could you put it in experimental and warn people the reason when we enabling it?

  11. etraut-openai commented on Jan 16, 2026

    @etraut-openai
    Contributor

    @SunRunAway, the previous experimental implementation had problems. It was causing many issues even for users who did not use the feature. If we bring it back, it will need to be redesigned.

  12. miraclebakelaser commented on Jan 17, 2026

    @miraclebakelaser
    Contributor

    I used the feature often as well.

    I use the following prompt as a hack to get codex to undo its changes:

    I don’t like it. Undo the changes you just made in your previous message using the patch tool. Do not use git commands to revert your work. Do not touch anything else that appears changed unless you modified it directly in this session.
    

    I use it often and it works reliably. It just takes longer. If you need to revert multiple turns, you have to send the prompt, wait for the llm to finish, backtrack and rinse-repeat.

    The only caveat is that it cannot bring back deleted files. I agree with @embedding-shapes - even if the undo feature existed, it should not be considered a first line of defense against accidental file deletion.

  13. embedding-shapes commented on Jan 17, 2026

    @embedding-shapes

    I'm not sure what the use of this feature is? Is my workflow different from others? How I work with Codex:

    • Start codex
    • Ask to do something
    • Once done, review it, and either:
      • "approve" it by committing it to git, then restart Codex from 0 and continue with something other task
      • or I got something wrong in the prompt, so I undo the work, then start a new conversation, making sure I fix the prompt
      • or it got something minor to fix, so do it myself/ask it to continue. Once done, git commit it, and restart Codex

    Is this workflow different from how other people are using it? Are others not using git and saving/undoing via git when needed?

  14. b20lopez commented on Jan 21, 2026

    @b20lopez

    I'm not sure what the use of this feature is? Is my workflow different from others? How I work with Codex:

    • Start codex

    • Ask to do something

    • Once done, review it, and either:

      • "approve" it by committing it to git, then restart Codex from 0 and continue with something other task
      • or I got something wrong in the prompt, so I undo the work, then start a new conversation, making sure I fix the prompt
      • or it got something minor to fix, so do it myself/ask it to continue. Once done, git commit it, and restart Codex

    Is this workflow different from how other people are using it? Are others not using git and saving/undoing via git when needed?

    Ohhh,,, you read its work.
    Hehe, for me who rely on /undo

    I only check which files its working in..
    I let it code. Observe the actual app.

    if it did what i wanted, good, If not.
    Most likely going to use /undo.

    If AI is having a hard time,, thats the only time i read its code and find a solution myself.

    other IDE's /coding agent have History you can switch back easily.
    Claude, Cursor, AntiGravity

    I dont know why in Codex they make it hard to undo

  15. 87 remaining items

  16. Mahkhmood9 commented on Oct 5, 2026

    @Mahkhmood9

    Until /undo is back, a workaround that works with any agent, including Codex: npx @abelo9996/snap-back wrap -- codex takes snapshots before and during the session into a separate shadow git repo, and snap-back undo restores the files, including ones that were deleted. Your own .git, index and stash are never touched. It cannot undo side effects outside the project (database writes, network calls).

    Disclosure: I wrote it. https://github.com/Abelo9996/snap-back

    Yalla with this malware dude... its 200,000 lines the whole github repo dude.

    Dude..

  17. Abelo9996 commented on Oct 5, 2026

    @Abelo9996

    Until /undo is back, a workaround that works with any agent, including Codex: npx @abelo9996/snap-back wrap -- codex takes snapshots before and during the session into a separate shadow git repo, and snap-back undo restores the files, including ones that were deleted. Your own .git, index and stash are never touched. It cannot undo side effects outside the project (database writes, network calls).
    Disclosure: I wrote it. https://github.com/Abelo9996/snap-back

    Yalla with this malware dude... its 200,000 lines the whole github repo dude.

    Dude..

    lol it's literally around 2k lines of code and I've tested it pretty thoroughly.... but sure

  18. Jason-Wang313 commented on Oct 7, 2026

    @Jason-Wang313

    I would also like /undo (or a separate /retract / /unsend command) to support retracting the most recently sent user message, not only reverting code or filesystem changes.

    A common case is sending a prompt by mistake, sending it to the wrong thread, or immediately realizing that it contains incorrect instructions. Stopping the turn does not fully solve this because the incorrect message remains in the conversation and may continue affecting later context.

    Ideally, the action would:

    • stop the active turn if it is still running;
    • remove or exclude the last user message from future model context;
    • restore the message text to the composer so it can be edited and resent;
    • clearly warn that tool actions already completed may not be reversible.

    A conversation-only retract would already be valuable even if code rollback remains a separate feature.

  19. Mahkhmood9 commented on Oct 11, 2026

    @Mahkhmood9

    30. > > Until /undo is back, a workaround that works with any agent, including Codex: npx @abelo9996/snap-back wrap -- codex takes snapshots before and during the session into a separate shadow git repo, and snap-back undo restores the files, including ones that were deleted. Your own .git, index and stash are never touched. It cannot undo side effects outside the project (database writes, network calls).
    > > Disclosure: I wrote it. https://github.com/Abelo9996/snap-back
    >
    >
    > Yalla with this malware dude... its 200,000 lines the whole github repo dude.
    > Dude..

     lol it's literally around 2k lines of code and I've tested it pretty thoroughly.... but sure
    

    something like this should be minified into 400 lines , cap

  20. Blackman99 commented on Oct 13, 2026

    @Blackman99

    Until a first-party /undo / /rewind lands, one gap git alone doesn't cover is untracked / gitignored files the agent deletes or rewrites mid-session. I built a small open-source CLI, agentckpt, as an external safety net that works with Codex (and Claude Code / Cursor / OpenCode / …) without forking them:

    pipx install git+https://github.com/Blackman99/agentckpt
    agentckpt init
    agentckpt snap -m "before agent"
    # … agent runs …
    agentckpt restore <id> --force

    Snapshots (including untracked files) live in a private shadow store under .agentckpt/. It never runs git add / git commit or moves branches in your real .git. agentckpt watch can auto-snap while the agent works. Honest limits: it restores the working tree, not the conversation; it can't undo DB/network side effects; respects .gitignore and skips files over 10 MiB by default.

    Disclosure: I wrote it. Demo: uvx --from git+https://github.com/Blackman99/agentckpt agentckpt demo · https://github.com/Blackman99/agentckpt

    Still worth upvoting this issue either way — a proper in-product rewind is the right long-term fix.

  21. bellowsai commented on Oct 19, 2026

    @bellowsai

    Disclosure: I'm Rob, and I built this.

    For anyone who needs this now: Bellows, a desktop app for Windows, macOS and Linux that runs Codex (alongside Claude, Gemini CLI, Qwen Code and any ACP agent), has undo for Codex built in.

    Every message you send records a restore point first. Choose Rewind files here on any earlier message, or Restore points in Ctrl+K, and the project goes back to how it was then: files Codex changed are put back, files it made are removed, and files it deleted come back, whether Codex did it with an edit or a shell command. Nothing needs to be committed, and the record lives in Bellows' own data folder, never in your project or your git history. Before you rewind, it also lists anything the agent did since that the files can't take back, like a push or a deploy.

    How it works: https://bellowsai.app/guides/undo-a-coding-agent-file-changes?utm_source=github&utm_medium=reply

    Give it a try and tell me what would make it better. We act fast on feedback.

  22. ayushdoesdev commented on Oct 20, 2026

    @ayushdoesdev

    This kept biting me too, mostly with untracked files. Codex would rm something that wasn't committed yet and it was just gone.

    I got annoyed enough that I built a small workaround while waiting for /undo to come back: unwreck It uses Codex hooks to snapshot the working tree at every turn, including untracked and gitignored files, and keeps the snapshots outside the repo. When something breaks, you run unwreck undo in another terminal.

    cargo install unwreck && unwreck hooks --write

    Disclaimer: I wrote it, and it's v0.1.0, so expect some rough edges. It doesn't replace a native /undo, but it's covered me for the "codex deleted my uncommitted stuff" case. Happy to hear if it breaks for anyone.

    Check it out: https://github.com/ayushdoesdev/unwreck

    Image
  23. balabommablock-cpu commented on Oct 20, 2026

    @balabommablock-cpu

    After reading the whole thread, I think the long back-and-forth is mostly people asking for three different things under one name:

    1. "Take back my message." I hit Enter too early, or sent a vague prompt, and want it out of the context. (@jbergq, @Jason-Wang313, @I571664)
    2. "Put my files back." Codex deleted or rewrote something git never saw: untracked files, .env, a file made and changed within one turn. (@zba, @S2thend)
    3. "Undo what it did out in the world." Commands, migrations, API calls. (@ignatremizov's write-up covers this well.)

    "Just use git" only answers part of #2. Wanting #1 is the most common case in this thread, and it's the one that needs no file system work at all.

    Suggested order, smallest and safest first:

    The real product question is what the word "undo" promises. Most people in this thread read it as "everything goes back the way it was". If the first version only does #1, I'd name it /rewind or /retract, or say clearly that files aren't touched, so nobody gets a nasty surprise.

    Open question for the team: @etraut-openai mentioned the old version caused problems even for people who didn't use it. Was that the per-turn file tracking cost? If so, a conversation-only first step avoids it completely, and could land well before the file part is redesigned.

  24. stanczykwyatt commented on Oct 30, 2026

    @stanczykwyatt

    In case it helps anyone while /undo is gone: I built mulligan, a small CLI that uses Codex's hooks to snapshot the project at every prompt and before every tool call, into a separate git repository outside your project. mulligan list shows the timeline, mulligan diff 3 what changed since a point, and mulligan undo 3 puts everything back, including changes made by shell commands, not just apply_patch. mulligan redo takes the undo back.

    mulligan setup codex prints the hooks for .codex/hooks.json (they need to be trusted in /hooks). It never touches your own repo's history, index or stash, and has no network access. One binary for macOS and Linux, MIT. It's been tested against Codex's documented hook format rather than many real sessions yet, so reports are welcome.

  25. Mahkhmood9 commented on Nov 5, 2026

    @Mahkhmood9

    @Blackman99
    Incorrect implementation of a very basic idea that exwist in git already
    I think anyway you can stretch it, it should bound to the source control you are using.
    git is powerful as it is. Learn the correct git functions
    https://git-scm.com/videos

    dont reinvate, things considered basic to why git was even invented and was needed

  26. Mahkhmood9 commented on Nov 5, 2026

    @Mahkhmood9

    27. This kept biting me too, mostly with untracked files. Codex would rm something that wasn't committed yet and it was just gone.
    I got annoyed enough that I built a small workaround while waiting for /undo to come back: unwreck It uses Codex hooks to snapshot the working tree at every turn, including untracked and gitignored files, and keeps the snapshots outside the repo. When something breaks, you run unwreck undo in another terminal.
    cargo install unwreck && unwreck hooks --write
    Disclaimer: I wrote it, and it's v0.1.0, so expect some rough edges. It doesn't replace a native /undo, but it's covered me for the "codex deleted my uncommitted stuff" case. Happy to hear if it breaks for anyone.
    Check it out: https://github.com/ayushdoesdev/unwreck
    Image

             [
               
             
                 <img alt="Image" height="600" src="https://private-user-images.githubusercontent.com/66489925/678696492-742654bc-c6d0-4ac8-92f1-58a61013bef0.gif?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTM4NzQwODAsIm5iZiI6MTc5Mzg3Mzc4MCwicGF0aCI6Ii82NjQ4OTkyNS82Nzg2OTY0OTItNzQyNjU0YmMtYzZkMC00YWM4LTkyZjEtNThhNjEwMTNiZWYwLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjExMDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYxMTA1VDEwMTYyMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFlZmY3NGVlNTI5ZDRkODQ5MDczMjM4ODVlZDM5N2Q5NjJhZWZkODk2ZTk0ZDkwZjZiMTdmZDNiNTUyZDQxNTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRmdpZiJ9.iVvkaJnHBNwzo8OZWaAPABYIpbHWRWnf3n3jS01L98o">
               ](https://private-user-images.githubusercontent.com/66489925/678696492-742654bc-c6d0-4ac8-92f1-58a61013bef0.gif?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTM4NzQwODAsIm5iZiI6MTc5Mzg3Mzc4MCwicGF0aCI6Ii82NjQ4OTkyNS82Nzg2OTY0OTItNzQyNjU0YmMtYzZkMC00YWM4LTkyZjEtNThhNjEwMTNiZWYwLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjExMDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYxMTA1VDEwMTYyMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFlZmY3NGVlNTI5ZDRkODQ5MDczMjM4ODVlZDM5N2Q5NjJhZWZkODk2ZTk0ZDkwZjZiMTdmZDNiNTUyZDQxNTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRmdpZiJ9.iVvkaJnHBNwzo8OZWaAPABYIpbHWRWnf3n3jS01L98o)
             
             
               
                 
                   
                 
                 
                   
                   
                 
               
               [
                 
                   
                 
               ](https://private-user-images.githubusercontent.com/66489925/678696492-742654bc-c6d0-4ac8-92f1-58a61013bef0.gif?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTM4NzQwODAsIm5iZiI6MTc5Mzg3Mzc4MCwicGF0aCI6Ii82NjQ4OTkyNS82Nzg2OTY0OTItNzQyNjU0YmMtYzZkMC00YWM4LTkyZjEtNThhNjEwMTNiZWYwLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjExMDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYxMTA1VDEwMTYyMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFlZmY3NGVlNTI5ZDRkODQ5MDczMjM4ODVlZDM5N2Q5NjJhZWZkODk2ZTk0ZDkwZjZiMTdmZDNiNTUyZDQxNTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRmdpZiJ9.iVvkaJnHBNwzo8OZWaAPABYIpbHWRWnf3n3jS01L98o)
    

    https://sapling-scm.com/
    is better

  27. vshulcz commented on Nov 21, 2026

    @vshulcz

    If the edit went through apply_patch before the loss, ~/.codex/sessions/ still holds the full - and + diff hunks in the rollout .jsonl even with no git history. I built a small cli (deja-vu) that walks those recorded hunks to reconstruct the file to -o without touching the working tree (0.8 ms lookup across 19,195 local sessions in our day-zero run). Raw shell rm on a file Codex never patched still needs a pre-turn snapshot, though.

  28. yarahmouni commented on Nov 23, 2026

    @yarahmouni

    While this is open: I'm considering building a small agent-agnostic tool for this gap. It would snapshot the working tree before each agent turn through hooks, then restore what changed or was deleted, including through shell commands, without needing git. Nothing exists yet; the README describes the plan: https://github.com/yarahmouni/shellundo

    If that would help you before a native fix lands, a 👍 on issue #1 there tells me whether it's worth building. A native /undo in Codex would of course be the better outcome.

  29. iqdoctor commented on Nov 23, 2026

    @iqdoctor

    +1

  30. Mahkhmood9 commented on Nov 29, 2026

    @Mahkhmood9

    While this is open: I'm considering building a small agent-agnostic tool for this gap. It would snapshot the working tree before each agent turn through hooks, then restore what changed or was deleted, including through shell commands, without needing git. Nothing exists yet; the README describes the plan: https://github.com/yarahmouni/shellundo

    If that would help you before a native fix lands, a 👍 on issue #1 there tells me whether it's worth building. A native /undo in Codex would of course be the better outcome.

    is a better link for nowhttps://github.com/yarahmouni/shellundo/blob/main/README.md?plain=1

    please rename the README.md into skill.MD

    and make a normal readme refrencing where its used

    but in my option i just to use my slopping agents slowly but surely , if my codex is making a mistake i tell it WHAT THE HELL DID YOU DO ??? PLEASE REVERT THIS ONE CHANGE "no i am not happy , please refactour the whole codebase"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    TUIenhancementsession

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions