🇫🇷 Cet article est aussi disponible en français.

What Codex Restores When You Resume a Session

What Codex Restores When You Resume a Session
🇫🇷 Cet article est aussi disponible en français.
📑 Table of Contents

TL;DR

According to the release notes, codex exec resume restores the saved working directory, workspace roots and sandbox permissions unless you override them. (Source : OpenAI — Codex 0.172.0 release)

A resumed thread is not a filesystem snapshot. Verify its effective context before handing it work, especially if the original scope was deliberately narrow.

Introduction

If you resume a coding job from another terminal, the transcript alone doesn’t tell the CLI where to run or what it can write. The pull request describes a concrete failure: a thread started with :read-only could resume with workspace write access when the new process defaulted to :workspace. (Source : OpenAI — Resume permission preservation, PR #62194)

OpenAI published Codex CLI 0.172.0 on November 24. Its change log says codex exec resume restores saved sandbox permissions, working directory and workspace roots unless explicitly overridden. This is a fix for the non-interactive command, not a promise about every Codex interface or every kind of saved state. (Source : OpenAI — Codex 0.172.0 release)

Three settings, three different questions

The working directory answers where a relative path starts. Workspace roots answer which locations the thread treats as part of its work. Sandbox permissions answer what operations its tools can perform. Those are different inputs. Starting in the right directory doesn’t prove that the workspace roots are right, and seeing the right roots doesn’t prove that the thread is read-only. If you supervise a fleet of jobs, report all three separately rather than reducing them to a single workspace_ok field.

Codex can recover built-in read-only permissions from older session history without widening read access. If it can’t load a saved named profile or restore saved read-only access, it requires an explicit permission selection. Directories passed with --add-dir are appended to the saved workspace roots. (Source : OpenAI — Resume permission preservation, PR #62194)

What upstream tested, and what to check yourself

The pull request lists a regression test that checks for a denied write on the first resumed shell call. It also lists tests for older read-only sessions, explicit permission overrides, and workspace-root preservation with and without --add-dir. That is OpenAI’s test coverage. Our local CLI was 0.171.0, so we did not independently test 0.172.0. (Source : OpenAI — PR #62194, Testing)

Use a disposable test repository without production credentials. Create a harmless fixture in a subdirectory and start a read-only thread there with known workspace roots. Record the session ID and resume that thread from a different directory without overriding its settings. Compare the CLI’s startup summary and recorded thread settings with the original context. The sandbox summary alone may not show every workspace root; if you can’t verify a setting, mark that part of the check inconclusive. This is a configuration check, not a test of whether the sandbox blocks writes.

Then change one benign input at a time. For example, vary which directory the operator launches from and verify the saved context remains the same, or explicitly choose a narrower scope and verify that the runtime reports it. Keep the fixtures synthetic and the actions read-only. This isolates the behavior you actually care about: whether the tool sees the intended boundary before it takes its first meaningful action.

Resume isn’t rollback

A branch can advance between runs. A configuration file can change, and a previously referenced fixture can move. A thread can retain its working directory and still be looking at a different commit. The release note gives no guarantee that the repository, untracked files, running subprocesses or external account state are restored. Treat those as separate checks, not implicit properties of the session ID.

A good handoff records the thread ID, canonical repository path, expected commit or branch, and intended permissions. For inspection workflows, a mismatch should stop the handoff before an agent runs consequential work. For editing workflows, record the state of any existing diff and leave it untouched until you know whether the previous run produced it. A correct resume should save you from restating the job, not from checking the repository.

This also affects rollout. If CI images and developer machines update independently, the same resume instruction can have different semantics across environments. Pin or report the CLI version alongside the session ID and keep failures to restore state distinct from provider errors or a missing transcript. You can troubleshoot a directory mismatch with evidence; a generic “resume failed” leaves three different investigations tangled together.

FAQ

Does this apply to all Codex sessions?

The cited release item specifically names codex exec resume. Check the release notes and test the corresponding entry point before extending the claim to interactive, remote or cloud sessions.

Can the saved policy be deliberately changed?

The release notes say explicit overrides are honored. Treat a deliberate change as a new execution decision that should be logged, not as an incidental property of whoever happened to launch the process.

Does resume reset my branch or restore missing files?

The documented change covers execution context, not a checkout or backup. Check repository state independently and do not infer filesystem recovery from a successful thread resume.

Further Reading

— The Agent Report