Codex config.toml: approvals, sandbox, and the rules they do not keep

Codex config.toml sets three things that shape every session: the model, the approval policy that decides when Codex stops to ask you, and the sandbox that decides what its commands may touch. None of the three holds a rule you stated in words. This post walks the file, the settings that matter, and the gap they leave: in our Codex benchmark, Codex broke rules from earlier sessions 49 times in 128 requests, and 3 times with Besydr, a program that runs beside the agent and learns from its sessions.

Where the Codex config file lives

Codex reads user-level configuration from ~/.codex/config.toml. A project can add overrides in .codex/config.toml, and for security Codex loads a project's .codex/ layers only when you trust the project. The CLI and the IDE extension share the same layers. The config basics page has the locations; the full reference lists every key.

An annotated config.toml

A minimal Codex CLI config that keeps the default posture explicit:

# ~/.codex/config.toml
# model = "..."                 # set the model your account serves
approval_policy = "on-request"  # when Codex pauses to ask you
sandbox_mode = "workspace-write" # what its commands may touch

# Network is off inside the sandbox by default. To allow it:
# [sandbox_workspace_write]
# network_access = true

The file also picks the model and provider; the config reference lists the keys. The two settings shown are the core safety controls of the file, and they answer different questions.

Approval policy

The Codex approval policy decides when the agent pauses for a human before running a command:

  • on-request: commands the sandbox allows run without approval; Codex asks when it wants to go beyond the sandbox, such as editing outside the workspace or reaching the network.
  • never: no approval prompts at all. This is what running Codex "full auto" means in practice: the agent works without asking, and the sandbox still decides what it can do. The flag form is --ask-for-approval never or -a never, and it combines with every sandbox mode.
  • A granular table, approval_policy = { granular = { ... } }, keeps some prompt categories interactive while automatically rejecting others.

One migration note: approval_policy = "untrusted" is retired and can prevent Codex from starting. The approvals and security page gives the replacement: sandbox_mode = "read-only" with approval_policy = "on-request" for interactive read-only use, or a per-project entry that preserves the stricter command-approval rule.

Sandbox modes

The Codex sandbox is an OS-enforced limit on what executed commands can touch, independent of approvals:

Mode What commands may do
read-only Read files; no writes
workspace-write Read and write inside the workspace; edits outside it need approval
danger-full-access No sandbox limits

Even in workspace-write, protected paths stay read-only: .git (including a pointer file's resolved git directory), .agents, .codex and .aws, recursively. Network access is off by default in the sandbox; sandbox_workspace_write.network_access turns it on. Codex also supports named permission profiles — the built-ins are :read-only, :workspace and :danger-full-access — for reusable filesystem and network policies.

Common combinations

The documentation names three postures:

Intent Flags or config Effect
Auto (the default preset) no flags, or --sandbox workspace-write --ask-for-approval on-request Reads, edits and commands in the workspace; approval outside it or for network
Safe read-only browsing --sandbox read-only --ask-for-approval on-request Reads and read-only commands; anything beyond can require approval
Full access --sandbox danger-full-access, or --dangerously-bypass-approvals-and-sandbox Reads, edits, commands and network without prompts

Pick the posture per task, not per machine: read-only for exploring an unfamiliar repository, the Auto preset for work you review, full access only where a container is the boundary.

What none of these settings does

A sandbox answers "may this command touch that file". An approval policy answers "must it ask first". Neither answers "is this what the developer asked for". Codex rules you state in words live in AGENTS.md or in chat, and the Codex benchmark measured what happens to them: they are advice, and advice decays across sessions.

Of 128 requests, five projects Codex alone With Besydr
Rules from an earlier session broken 49 3
Corrections the developer typed 60 25

Bar chart: rules from an earlier session broken, of 128 requests on five projects, Codex alone 49, with Besydr 3. Both models together, means of repeated runs.

The config file cannot close that gap because it has no key for your sentences. A study of 20,574 coding-agent sessions (Tang et al., EMNLP 2026) found constraint violations in 49.49% of pushback episodes in CLI sessions — the kind of session Codex runs.

Besydr closes the gap in two ways. It learns rules from your corrections and repeats them in later requests; the benchmark attributes the rule retention above to that learning. And it adds the missing check through Codex's own hooks: a call that conflicts with your words can be denied, with your sentence as the reason. Two honest limits from the client documentation: Codex runs a hook only after you review and trust it in /hooks, and Codex's own documentation says its hooks are not a complete enforcement boundary, so a denied call is a strong default, not a guarantee. The benchmark post has every number and the AGENTS.md details; the local program is free with octomind and needs a licence with Codex after a trial.

Diagram of the three questions a command faces: the sandbox asks may it touch this, the approval policy asks must it ask first, and your words ask is this what I asked for. Config answers the first two; Besydr checks the third.

Sources and method