Day 3, 30 minutes · beginner
Why it matters
Handing off work only feels safe when you know where the agent stops. Codex answers that with two separate settings. The sandbox decides what Codex can do at all: which folders its commands may write in and whether they can reach the internet. The approval policy decides when Codex must stop and ask you before it goes past that fence.
Most people never look at these settings and then feel either nervous ("what is it running?") or annoyed ("why does it keep asking?"). Both come from not knowing the defaults. Once you know them, you can loosen them for a trusted job and tighten them for a review, on purpose.
Today you read the settings of your own session, watch Codex stop at the edge of the sandbox, switch between the two built-in presets, and save a read-only profile you can start with one command. At the end you can say, in one sentence, what Codex may do in your repository without asking.
The two controls
The Codex docs describe them like this:
- Sandbox mode (
sandbox_mode):read-only,workspace-writeordanger-full-access. Inworkspace-writethe commands Codex runs can write only in the workspace (your project folder plus temporary folders) and have no network access. The sandbox also applies to every program Codex starts, such as git or a test runner, not only to its own file edits. - Approval policy (
approval_policy): the two values you need here areon-request(Codex asks when it needs to go beyond the sandbox) andnever(Codex never asks and simply works within the sandbox).
The Auto preset is workspace-write plus on-request: Codex reads, edits and runs commands in your folder by itself and asks before it edits outside the folder or uses the network. Read Only lets Codex read files and run commands inside a read-only sandbox, so it cannot edit your files on its own; actions outside the sandbox can need your approval. Codex suggests Auto when it starts in a git repository and read-only in a plain folder.
A few protections stay on even in Auto. Inside your workspace, the .git, .codex and .agents folders are read-only for Codex's commands. That is why you commit yourself in this course.
Three ways to set them
- For this session: the
/permissionscommand, mid-session, without restarting. - For one start: flags, such as
codex --sandbox read-only --ask-for-approval on-request. - For good: a setting in
~/.codex/config.toml, or a separate profile file such as~/.codex/review.config.tomlthat you choose with--profile review. A profile file only needs the lines that differ from your normal settings.
Settings from flags beat project settings, which beat profiles, which beat your personal config.toml.
The steps
- Read your current settings with
/status. - Find the edge. Ask for something just outside the workspace and see Codex stop and ask. Say no. (If Codex only explains that it cannot do it, that is fine too: you have found the edge.)
- Tighten and loosen with
/permissions: Read Only, then back to Auto. - Save a review profile for sessions where Codex should only read and advise, and start it with
--profile review.
Follow the guide for Codex below for the exact commands.
What to avoid
--yolo(long name--dangerously-bypass-approvals-and-sandbox) turns off both the sandbox and approvals. The CLI reference says to use it only inside an externally hardened environment. Not on your laptop.- Old settings from older guides.
approval_policy = "untrusted"is retired and can stop Codex from starting;--full-autono longer exists. If you copy a config from somewhere, check it against the current docs. - Turning on network access to fix one command. Ask yourself whether you can approve that one action instead. If a task needs another folder,
--add-diradds write access for that one extra folder next to the workspace.
Example: Benthe's sentence
After today, Benthe wrote one line at the top of her notes: "In puffinreach-kites Codex may edit files and run commands inside the repo by itself, and asks before network use or anything outside it. For reviews I use codex --profile review." When Codex later asked to fetch a web page during a task, she knew exactly why it stopped, and that saying no was safe.
On Windows
When you run Codex in PowerShell, it uses a native Windows sandbox. In WSL2 it uses the Linux sandbox, which needs the bubblewrap package. If your settings look different from this lesson, /debug-config shows the order of the settings layers and the policies that apply. Your organisation may also lock some values on a managed computer.
Deeper dive
Today's actions
Ticks are not saved without an accountDo it in OpenAI Codex
OpenAI Codex
- Go into puffinreach-kites, start
codexand type/status. Note the approval policy and the writable folders. In a trusted git repository this is usually the Auto setting. - Paste this task. Writing outside the workspace needs your approval in Auto, so Codex should stop and ask. Answer no.
Create a file called outside-test.txt in the folder one level above this repository. - Type
/permissionsand press Enter. Choose Read Only, then run/statusto see the change. - Paste this task. In Read Only, Codex cannot edit your files on its own. It should ask first or tell you it cannot. Answer no if it asks.
Add a fourth kite to the price list: Night Owl, 59.00. - Type
/permissionsagain, choose Auto and type/exit. - Create a profile file named
review.config.tomlin your Codex home folder (~/.codexon macOS and Linux,%USERPROFILE%\.codexon Windows) with these two lines.sandbox_mode = "read-only" approval_policy = "on-request" - Start Codex with the profile and check it with
/status. Use this for sessions where Codex should only read and advise.codex --profile review
Note: For one session only, flags do the same: codex --sandbox read-only --ask-for-approval on-request. The setting approval_policy = "untrusted" is retired and can stop Codex from starting, and --full-auto no longer works. On Linux and WSL2, install bubblewrap first, as the sandbox page says.
Paid planSame as lesson 1: the Codex CLI with ChatGPT Plus, Pro, Business, Edu or Enterprise, or with an OpenAI API key.
Create a free account to save your progress
Free, and no payment details. Your ticks and finished lessons are kept, on every device.
Create a free account I already have an accountCreate a free account to save your progress. Sign in or sign up