After exiting the Codex CLI, you don't need to redescribe the entire task; just run codex resume select the session to save; To continue the most recent session in the current directory, use codex resume --last. What is restored is the original session record and context, not just copying the last answer.
Select the restore command by scene
While in the Codex interface, enter /resume, then select the record you want to continue from the session list. When you have returned to the system terminal, you can use the following methods:
# 打开会话选择器
codex resume
# 继续当前工作目录最近一次会话
codex resume --last
# 按会话 ID 或已命名的会话恢复
codex resume SESSION_IDAutomated tasks require a different set of commands. In two stages of the pipeline, you can first complete the check, then resume the same non-interactive session to perform the repair:
codex exec "检查并列出并发问题"
codex exec resume --last "修复刚才确认的问题并运行测试"Why can't I find that session in the list?
The most common reason is that the startup directory has changed. --last By default, only sessions corresponding to the current working directory are viewed; If you have already switched to another repository or parent directory, you can add --all to expand the search scope or use the session ID directly. The second situation is when the session is archived; it will not appear in the regular activity list and needs to be restored in the archived session first.
Local session records default to $CODEX_HOME/sessions, usually ~/.codex/sessions; The archive record is located at $CODEX_HOME/archived_sessions. Don't manually modify these records just to retrieve tasks; prioritize using resume and unarchive commands.
After restoration, first confirm the site before continuing to modify it
When restoring an old session, the code on the disk may have already been modified by you or another tool. First, have Codex run the git status, view the current branch and existing diff, and then send the next task. You can simply explain:
First, check the current branch, unsubmitted modifications, and the status of the previous task; only report the differences, do not immediately modify the file.
If you want to focus on another goal now, don't stick to old conversations. Creating new sessions with /new is more stable; Only when task objectives, warehouse sites, and front-order decisions remain continuous is resume appropriate.