All guides

Codex approval modes and sandbox explained (on-request, never, workspace-write, --yolo)

Updated 19 November 2026 · 5 min read

The Codex CLI decides what runs without asking you with two settings that work together. The sandbox mode sets what Codex can technically do: read-only, workspace-write (edit files in the project, no network by default) or danger-full-access. The approval policy sets when Codex stops to ask: on-request (it asks when it needs to go beyond the sandbox) or never. The default Auto preset is workspace-write with on-request. --dangerously-bypass-approvals-and-sandbox, alias --yolo, removes both and is meant only for environments that are already isolated. Switch mid-session with /permissions.

01The two layers

Sandbox mode (--sandbox/-s, or sandbox_mode in ~/.codex/config.toml) is enforced by the operating system when Codex runs commands:

SandboxWhat commands can do
read-onlyRead files and run commands inside the read-only sandbox. No edits, no network.
workspace-writeRead, and write inside the workspace (the project folder and temporary folders). No network unless you enable it.
danger-full-accessAnything your user account can do, with network.

Inside workspace-write, .git, .codex, .agents and .aws folders stay read-only.

Approval policy (--ask-for-approval/-a, or approval_policy) decides when Codex asks you:

PolicyBehaviour
on-requestActions inside the sandbox run without asking. Codex asks before anything that needs more: network access, edits outside the workspace, some tool calls.
neverCodex never asks. Anything the sandbox blocks fails and the failure goes back to the model.
{ granular = { ... } }Keep some prompt categories interactive and automatically reject others.

Two older values are gone: untrusted is no longer supported and can stop Codex starting, so remove it from your config; on-failure is deprecated. For codex exec, --full-auto is no longer supported; use --sandbox workspace-write.

02The presets

PresetFlagsWhat it means
Auto (default)none, or --sandbox workspace-write --ask-for-approval on-requestReads, edits and runs commands in the project; asks to go outside it or use the network
Read Only--sandbox read-only --ask-for-approval on-requestLooks and plans; asks before anything else
Read-only CI--sandbox read-only --ask-for-approval neverNever asks, can't change anything
Auto-reviewAuto plus approvals_reviewer = "auto_review"A reviewer agent answers eligible approvals instead of you
Full access--dangerously-bypass-approvals-and-sandbox (--yolo)No sandbox, no approvals

When you start Codex in a folder under version control, it recommends Auto; elsewhere it recommends read-only. Depending on your setup, it may start read-only until you trust the folder.

Type /permissions in a session to switch presets, for example from Read Only while planning to Auto when you're ready for edits. /status shows which folders count as the workspace.

03Network access

In workspace-write, commands have no network by default, which is the most common reason Codex asks for approval (installing packages, calling APIs). To allow it inside the sandbox:

[sandbox_workspace_write]
network_access = true

or for one session: codex -c 'sandbox_workspace_write.network_access=true'. That keeps the file-system sandbox while removing the network prompts.

04Auto-review

approvals_reviewer = "auto_review" (or --approve-for-me, which also uses workspace-write) sends eligible approval requests to a reviewer agent before they reach you. It checks for data exfiltration, credential probing, weakening security and destructive actions; it lets low and medium risk through when policy allows, and denies critical risk. It uses extra model calls. /approve retries one recent denial if you disagree.

05Per-project trust

You can mark a project as untrusted in your user config to make Codex ask before commands there unless a rule allows them:

[projects."/Users/you/code/client-repo"]
trust_level = "untrusted"

This also stops Codex loading that project's .codex/ config and hooks.

06Which mode is safe to leave running?

  • Auto with network as needed is the sensible default for walking away. Codex works freely inside the project, and anything outside it still needs a yes.
  • Auto-review cuts prompts further, at the cost of extra usage and a model, not you, making those calls.
  • never with workspace-write suits automation: Codex never stops, and anything the sandbox blocks simply fails.
  • --yolo belongs in a container or VM you can throw away. On your own machine it gives Codex everything your account can reach with no checks.

07Approvals and your phone

Every approval request fires Codex's PermissionRequest hook first, which is how approvals can reach you away from the keyboard. With Auto, the requests that remain are the ones worth a human look: network access, edits outside the project, risky tool calls. Notifier for Codex sends them to an iPhone or Android app, where you approve or reject (with a note Codex reads); if you're at the keyboard, the terminal asks as usual. It is independent and not affiliated with OpenAI. See approving Codex commands from your phone and, for the hook itself, the PermissionRequest guide.

With never or --yolo there are no approval prompts, so nothing goes to the phone except "finished" alerts.

08FAQ

What's the difference between --sandbox and --ask-for-approval?

The sandbox is what Codex can do; the approval policy is when it asks. workspace-write with on-request lets it work in the project and ask for anything beyond. danger-full-access with never removes both checks.

Why does Codex keep asking to use the network?

workspace-write has no network by default. Turn on sandbox_workspace_write.network_access for the project or the session.

Codex won't start after an upgrade and mentions approval_policy. Why?

approval_policy = "untrusted" is no longer supported. Remove it from config.toml, profiles and scripts, and use on-request or per-project trust_level = "untrusted" instead.

Is --yolo the same as --dangerously-bypass-approvals-and-sandbox?

Yes, it's the short alias.

Can a hook approve requests instead of me?

Yes. A PermissionRequest hook can return allow or deny. For routine cases, auto-review or sandbox settings are usually simpler and safer.

Notifier for Codex Get a push on your phone when Codex finishes or needs you, then approve, reject or answer from there. The codex-notifier command line tool is free on Mac, Windows and Linux.