# Permissions, sandboxes and approval modes across Claude Code, Codex and Cursor

URL: https://developertoolkit.ai/en/workflows/harness/permissions-and-sandboxing/
Description: A cross-tool matrix of approval modes, OS sandboxes and network egress in Claude Code, Codex and Cursor, with the posture to use per risk class and run type.

Permissions and sandboxes in Claude Code, Codex and Cursor are three separate controls: an approval layer that decides whether an action runs, an OS sandbox that limits what a shell command can read and write, and a network allowlist that limits where it connects. An unattended run is safe only when all three are set, not the approval layer alone.

Your agent asked for approval forty times in one refactor, so someone added the bypass flag "just for today". Two weeks later that flag sits in the CI job that triages public issues, the runner holds an npm publish token, and nobody can say which boundary would stop an injected `curl`. This page is for the **developer** configuring a session, the **tech lead** who owns shared settings, and the **CTO** who signs off on what unattended agents may reach. It is step 4 of the [developer track](/en/start/developer/), after [repository context](/en/developer-scorecard-guide/claude-md-context/), because every later step, from worktrees to the [issue-to-PR pipeline](/en/workflows/automate/issue-to-pr-pipeline/), assumes these boundaries exist.

## What this permissions reference gives you

- A matrix of approval, sandbox, network and credential controls in Claude Code v2.1.283, Codex CLI 0.157.1 and Cursor.
- A posture table per risk class and per run type (interactive, background, CI).
- Configuration you can commit for all three tools, including a Codex GitHub Actions job.
- A canary test that proves the boundary holds, instead of trusting a settings file.
- Three copy-paste prompts and failure modes with recovery steps.

## What are the three layers every agent run needs?

The vendors use different words for the same three questions. A strong answer to one does not cover the others.

| Layer | The question it answers | Claude Code | Codex | Cursor |
| --- | --- | --- | --- | --- |
| **Approval** | Does this action run, and who says yes? | Permission modes and allow/ask/deny rules | Approval policy and auto-review | Run modes and Auto-review |
| **OS sandbox** | What can a running command read and write? | Sandboxed Bash tool | Sandbox or permission profile | Sandbox for shell commands |
| **Network egress** | Where can a running command connect? | Sandbox proxy with a domain allowlist | Profile network setting | Not verified (see below) |

The approval layer judges the command string before it runs. The sandbox is enforced by the operating system on the running process. Anthropic's sandboxing guide puts the difference plainly: the sandbox boundary "holds regardless of what the model chose to run and even if an allowed command does more than its name suggests". A deny rule on `Bash(curl *)` stops `curl`, not `python -c` opening a socket; the sandbox stops both.

Outside all three sits the **outer boundary**: the laptop, container, VM or cloud environment the agent runs in, and its credentials. Choosing it is covered in [ephemeral environments](/en/workflows/harness/ephemeral-environments/) and the tool catalogue in [agent sandboxes compared](/en/ecosystem/agent-tools/sandboxes/).

## How do Claude Code, Codex and Cursor compare on permissions and sandboxing?

Checked on 2026-09-26 against `claude --help` 2.1.283 and Anthropic's permission, sandboxing and cloud-environment docs; `codex --help` 0.157.1, the `rust-v0.157.1` source and the `openai/codex-action` README; and the `@cursor/sdk` 1.0.32 package. Cursor's documentation site was unreachable from our environment on that date, so the Cursor column holds what the SDK package or the 2026-08-28 docs check confirms, plus the run-mode names that Cursor's Run modes page gives (checked 2026-10-12).

| Control | Claude Code 2.1.283 | Codex CLI 0.157.1 | Cursor |
| --- | --- | --- | --- |
| Approval modes | `default` (shown as **Manual**), `acceptEdits`, `plan`, `auto`, `dontAsk`, `bypassPermissions`; Shift+Tab cycles | `approval_policy`: `untrusted`, `on-request` (default), `granular`, `never`. The `-a` flag accepts only `on-request` and `never` | A **Run modes** page under Agent security: Auto-review (the recommended default since Cursor 3.6), Allowlist and Run Everything, under Settings > Agents > Approvals & Execution (checked 2026-10-12) |
| A model approves instead of you | Auto mode: a classifier (Claude Sonnet 5 by default) reviews actions. It is the starting mode for interactive sessions from v2.1.283 (both release channels on 2026-10-12) | Auto-review: `approvals_reviewer = "auto_review"` in config, or `--approve-for-me` | Auto-review (SDK option `local.autoReview`) |
| Command rules | `permissions.allow`, `ask`, `deny`, evaluated deny, then ask, then allow | `.rules` files (experimental) decide which commands may run outside the sandbox | Hooks: JSON over stdio that "can observe, block, or modify behavior" |
| OS sandbox | Bash, PowerShell and Monitor commands. macOS Seatbelt, Linux and WSL2 bubblewrap; native Windows not supported | Every model-generated shell command. macOS Seatbelt, Linux and WSL2 bubblewrap; WSL1 rejected | SDK `local.sandboxOptions`; `/sandbox` in the CLI command list |
| Default write boundary | Working directory, a per-user temp directory, and directories added with `--add-dir` | `:workspace` profile writes the workspace; `:read-only` writes nothing | Not verified |
| Default network | No domains pre-allowed; first use of a host prompts, or goes to the classifier in auto mode | `:workspace` "does not grant network access" (codex-action README; confirmed locally, see the canary below) | Not verified |
| Egress allowlist | `sandbox.network.allowedDomains`, `deniedDomains`, `strictAllowlist`, managed `allowManagedDomainsOnly` | Named `[permissions]` profiles carry per-domain allow and deny (beta); legacy `network_access` is all or nothing | Not verified |
| Secrets in the environment | `sandbox.credentials`: `deny` or `mask` for files and variables; nothing is protected by default | `shell_environment_policy`: `ignore_default_excludes` defaults to `true`, so `*KEY*`, `*SECRET*`, `*TOKEN*` variables reach commands unless you set it to `false` | Not verified |
| Full bypass | `--dangerously-skip-permissions`; refused under root or `sudo` outside a recognised sandbox | `--dangerously-bypass-approvals-and-sandbox` | Not verified |
| Admin lock | Managed settings: `disableBypassPermissionsMode`, `disableAutoMode`, `sandbox.failIfUnavailable`, `allowManagedDomainsOnly` | `requirements.toml`: `allowed_approval_policies`, `allowed_approvals_reviewers`, `allowed_permission_profiles`, `experimental_network`, `rules` (checked against `config_requirements.rs` at `rust-v0.157.1`) | An `mdm` settings layer (SDK `settingSources`) |

Notes: the Claude Code sandbox covers shell commands only; the Read, Edit and Write tools obey permission rules, not the sandbox. Codex permission profiles (beta, from 0.138.0) and legacy `--sandbox` values "do not compose", so pick one per configuration. The two full-bypass flags in the matrix belong only inside a disposable container or VM with restricted egress and no production credentials.

## Which posture fits each risk class and run type?

A [risk class](/en/ladder/one-map/) belongs to a change, not a team. A run gets the posture of the **highest class it can touch**: a "docs only" task in a repository that holds billing code runs with the billing posture unless the sandbox denies it those paths. The tech lead owns this table per repository; the CTO or security owner signs off on the critical row and every exception.

| Risk class | Approval layer | Filesystem | Network | Credentials in the environment |
| --- | --- | --- | --- | --- |
| **Low** (docs, internal tooling) | Reviewer model (auto mode, auto-review) | Workspace write | Package registries only | None beyond a read-only repository token |
| **Medium** (feature logic behind a flag) | Reviewer model, plus ask rules on `git push` and dependency changes | Workspace write, secret paths read-denied | Registries plus named internal hosts, strict allowlist | Masked or none |
| **High** (public API, tests, CI config) | Reviewer model for code; ask rules on `.github/`, test and CI config paths | Workspace write; CI config edits prompt | Strict allowlist, no wildcards on hosts that accept uploads | None |
| **Critical** (auth, money, migrations, secrets, the harness itself) | Manual or plan mode; never bypass | Workspace write inside a disposable container or VM | No egress beyond the registry mirror | No production credentials, ever |

A background or CI run has nobody to answer a prompt, so the run type limits which approval layer works:

| Run type | Approval layer that works | What replaces the human | Outer boundary |
| --- | --- | --- | --- |
| **Interactive** | Any mode; auto mode or auto-review for long tasks | You, for the prompts that remain | Your laptop, so the sandbox carries the weight |
| **Background or cloud** | Reviewer model; bypass only inside a disposable VM or container | The classifier or reviewer, plus the network level of the cloud environment | A vendor VM or your own runner |
| **CI** | An exact allowlist (`dontAsk`) or `never` with a profile | The allowlist: anything that would prompt and is unlisted is denied (reads in the working directories and read-only commands still run) | A disposable runner with scoped tokens |

**Reviewer models are not a sandbox**

Claude Code's auto mode and Codex auto-review judge intent; they do not contain a process. Anthropic lists the isolation auto mode needs as "None; a sandbox or container adds defense in depth". From medium class up, run the reviewer inside the OS sandbox, not instead of it.

## Configure the interactive posture

Commit the team baseline to the repository and put the non-negotiable parts in managed settings, which users cannot override. [Managed policy](/en/org/managed-policy/) covers distributing one policy across tools.

**Claude Code**

Project baseline in `.claude/settings.json` (medium class): sandbox on, no unsandboxed retry, limited egress, two tokens stripped from sandboxed commands, and a prompt for pushes and CI edits:

```json
{
  "permissions": {
    "deny": ["Read(./.env)", "Read(./.env.*)", "Bash(terraform apply *)"],
    "ask": ["Bash(git push *)", "Edit(/.github/**)"]
  },
  "sandbox": {
    "enabled": true,
    "allowUnsandboxedCommands": false,
    "network": {
      "allowedDomains": ["registry.npmjs.org", "github.com", "api.github.com", "codeload.github.com"]
    },
    "credentials": {
      "files": [
        { "path": "~/.aws/credentials", "mode": "deny" },
        { "path": "~/.ssh", "mode": "deny" }
      ],
      "envVars": [
        { "name": "NPM_TOKEN", "mode": "deny" },
        { "name": "GITHUB_TOKEN", "mode": "deny" }
      ]
    }
  }
}
```

Managed settings for the organization, delivered by MDM or server-managed settings, hold the keys a checked-out repository cannot set or relax:

```json
{
  "permissions": { "disableBypassPermissionsMode": "disable" },
  "sandbox": {
    "enabled": true,
    "failIfUnavailable": true,
    "allowUnsandboxedCommands": false,
    "network": { "strictAllowlist": true, "allowManagedDomainsOnly": true }
  }
}
```

- The allowlist names exact GitHub hosts instead of `*.github.com`, because the wildcard would also match `gist.github.com` and `uploads.github.com`, both places an injected command could send data.
- Project settings cannot start a session in `auto` or `bypassPermissions`; those values are ignored there. Set the starting mode in user or managed settings.
- `strictAllowlist` denies unlisted hosts instead of prompting, and has no effect in a repository's settings files. It needs v2.1.219 or later.
- On Linux and WSL2, install `bubblewrap` and `socat` first. Run `/sandbox` in a session: if it shows only a Dependencies tab, the sandbox is not running.
- `/permissions` lists every active rule and the file it comes from, and shows recent auto-mode denials.

**Codex**

User or project `config.toml` (medium class). The built-in `:workspace` profile writes only the workspace and grants no network. Setting `ignore_default_excludes = false` strips variables named like keys, secrets and tokens from shell commands:

```toml
default_permissions = ":workspace"
approval_policy = "on-request"
approvals_reviewer = "auto_review"   # a reviewer agent decides escalations; default is "user"

[shell_environment_policy]
ignore_default_excludes = false
```

Admin constraints go in `requirements.toml`, which users cannot override. Its keys are not the `config.toml` names: it takes `allowed_approval_policies`, `allowed_approvals_reviewers`, `allowed_permission_profiles`, `experimental_network` and `rules`, among others (checked against `config_requirements.rs` at `rust-v0.157.1`). Writing `approval_policy = "never"` there constrains nothing.

- Do not add `sandbox_mode` or `--sandbox` to a configuration that uses `default_permissions`; the two systems do not compose.
- `/permissions` in the TUI shows and changes what Codex may do; `/approve` retries one auto-review denial.
- When a task needs a package registry, install dependencies first or define a named `[permissions]` profile with per-domain network entries (beta; check the schema in the Codex source).

**Cursor**

Cursor documents approval and sandbox behaviour on its **Run modes** page under Agent security. The modes are **Auto-review** (the recommended default since Cursor 3.6), **Allowlist** and **Run Everything**, under **Settings > Agents > Approvals & Execution** (Cursor docs, checked 2026-10-12). Cursor says Auto-review is not a security boundary, and that Cloud Agents do not use run modes because they run inside their own dedicated machine. Also verified:

- **Auto-review** exists for local tool calls, and the SDK exposes it as `local.autoReview`.
- **Sandboxing** can be switched on per run through the SDK (`local.sandboxOptions`), and `/sandbox` is listed among the Cursor CLI slash commands.
- **Hooks** "can observe, block, or modify behavior". Version a hook in the repository that blocks shell commands touching unapproved hosts or secret paths; take the event names from Cursor's hooks page.
- **Cloud Agents** "run in isolated VMs in the cloud", which moves the blast radius off the developer laptop.

Choose the most restrictive run mode your team can work in, turn the sandbox on, and run the canary below to see what it blocks.

## Configure background and cloud runs

A background run cannot answer prompts, so the approval layer decides alone and the environment's network level becomes the main egress control.

**Claude Code**

- **Cloud sessions** (claude.ai/code, routines) have a **Network access** level: **None**, **Trusted** (package registries, GitHub and cloud SDKs; the default), **Full** or **Custom**. GitHub traffic, enabled MCP connectors and the Anthropic API bypass it, so disable connectors a task does not need.
- Cloud sessions ignore `defaultMode: "bypassPermissions"` and `"dontAsk"` from settings files, so a repository cannot start one in bypass mode.
- **Local background sessions** started with `--bg` are refused in bypass mode until you have accepted the bypass warning once interactively. In background sessions, strict sandbox mode also covers commands you type at the `!` prompt.

**Codex**

- `codex exec` runs non-interactively with the same permission profile as the TUI, and always with approval `never` unless you pass `--approve-for-me`: in 0.157.1 it has no `-a` of its own, and neither `approval_policy` in config nor a `codex -a … exec` prefix changes that.
- Codex cloud tasks run "in isolated cloud environments" configured per environment (OpenAI docs, checked 2026-08-28). Treat the environment's network setting as the egress control, and check it before connecting a repository that holds deployment credentials.

**Cursor**

- Cloud Agents run in isolated VMs; give each VM its own scoped credentials, never a personal token.
- For local runs driven from code, the SDK makes the posture explicit. When `autoReview` or the sandbox is on, MCP server tool calls that would need interactive approval "fail closed":

```js
// run-agent.mjs
import { Agent } from '@cursor/sdk';

const MODEL_ID = process.env.CURSOR_MODEL_ID; // an id from Cursor.models.list()

const agent = await Agent.create({
  apiKey: process.env.CURSOR_API_KEY,
  model: { id: MODEL_ID }, // pick one from Cursor.models.list()
  tools: ['read', 'grep', 'glob', 'edit', 'shell'],
  local: {
    cwd: process.cwd(),
    autoReview: true,
    sandboxOptions: { enabled: true },
    settingSources: ['project', 'team', 'mdm'],
  },
});

const run = await agent.send('Run the unit tests and fix the failing test in src/billing.');
const result = await run.wait();
console.log(result.status); // 'finished', 'error' or 'cancelled'
if (result.status !== 'finished') process.exit(1);
```

`CURSOR_MODEL_ID` holds a model ID from `Cursor.models.list()`; the SDK requires one for local agents. `result.status` is `finished`, `error` or `cancelled`. Checked against `@cursor/sdk` 1.0.32.

## Configure CI runs

In CI an agent meets untrusted text: issue titles, pull request bodies and diffs from forks. Give the job an exact allowlist, a workspace-only sandbox and a token scoped to its one task. The GitHub Actions hardening (`pull_request_target`, token permissions, OIDC) lives in [agent identity, credentials and secrets](/en/org/agent-identity-and-secrets/).

**Claude Code**

`dontAsk` denies everything that would prompt (reads in the working directories and read-only commands still run), so the allowlist adds only what the run needs. `--permission-prompts none` makes sure nothing waits for an answer. `--settings` turns the sandbox on for this run and forbids the unsandboxed retry, and the `--disallowedTools` rule keeps the tests, which are the oracle, out of reach of `Edit` (adjust `/tests/**` to your layout, using the same path form as the other rules on this page):

```bash
# CI: run and fix tests, nothing else. --bare, --setting-sources "" and
# --strict-mcp-config load no hooks, settings, CLAUDE.md or MCP servers from the
# checkout, which may hold a contributor's code; only --settings below applies.
claude -p "Run the test suite and fix failing tests in src/. Do not edit tests." \
  --bare --setting-sources "" --strict-mcp-config \
  --permission-mode dontAsk \
  --permission-prompts none \
  --settings '{"sandbox":{"enabled":true,"allowUnsandboxedCommands":false}}' \
  --allowedTools "Read" "Edit" "Bash(npm test)" "Bash(npm run lint)" \
  --disallowedTools "Edit(/tests/**)"
```

`claude -p` sessions start in Manual, or in auto mode on third-party providers or with telemetry off (from v2.1.285), where a classifier decides what runs instead of your list. Keep `--permission-mode dontAsk` in the command: it denies everything that would prompt, on every provider. For a read-only triage job, `--restricted` removes the command-running tools and WebFetch unless `--tools` names them, and refuses `bypassPermissions`.

**Codex**

The `openai/codex-action` README recommends a permission profile over legacy sandbox flags, and its default `safety-strategy: drop-sudo` removes the runner user's `sudo` before Codex starts (since v1.13, 2026-10-05, Linux `drop-sudo` needs `setfacl`, the `acl` package, and ACL support on `/run`):

```yaml
- name: Run Codex
  uses: openai/codex-action@v1
  with:
    openai-api-key: ${{ secrets.OPENAI_API_KEY }}
    permission-profile: ":workspace"
    safety-strategy: drop-sudo
    prompt: |
      Run the unit tests and fix failing tests in src/. Do not edit tests.
```

Install dependencies in an earlier step: `:workspace` grants no network. Supplying both `permission-profile` and `sandbox` fails before Codex starts. GitHub-hosted Windows runners require `safety-strategy: unsafe`, so keep agent jobs on Linux or macOS. From a plain shell:

```bash
codex exec -c 'default_permissions=":workspace"' \
  "Run the unit tests and fix failing tests in src/. Do not edit tests."
```

**Cursor**

The verified route is the SDK script above, saved as `run-agent.mjs` and run from a CI step. It installs `@cursor/sdk` in an earlier step and reads its key from a secret and its model ID from a repository variable:

```yaml
- run: npm install @cursor/sdk@1.0.32
- name: Run Cursor agent
  run: node run-agent.mjs
  env:
    CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
    CURSOR_MODEL_ID: ${{ vars.CURSOR_MODEL_ID }}
```

The script keeps `sandboxOptions: { enabled: true }` and exits non-zero when the run does not finish. Cursor also documents a headless CLI print mode (`-p, --print`) for GitHub Actions, checked on 2026-08-28; its permission flags were not verifiable here. Run the job on a disposable Linux runner with a repository-scoped token, and prove the boundary with the canary below before the job sees public input. When the job checks out a contributor's commit, drop `'project'` from `settingSources`, so no hooks or MCP configuration load from that checkout while `CURSOR_API_KEY` is in the environment. The cross-tool CI setup is compared in [headless agents in CI](/en/ecosystem/agent-tools/headless-agents-ci/).

## How do you prove the sandbox boundary holds?

A settings file is a claim. A canary is evidence: a command that must fail under the policy, run the way the agent runs. Run it when you set a posture, on every harness settings change, and after each tool upgrade.

1. Pick three probes for the posture: a write outside the workspace, a read of a secret path, and a connection to a host that is not on the allowlist.

2. For Codex, run the probes through `codex sandbox`, which applies the same sandbox the agent gets. With codex-cli 0.157.1 on Linux, this run printed `ok`, then `Read-only file system` for `/etc`, then a refused connection for `curl`:

   ```bash
   codex sandbox -c 'default_permissions=":workspace"' -- sh -c \
     'echo ok > probe.txt && cat probe.txt; echo x > /etc/probe; curl -sS -m 5 https://example.com'
   ```

3. For Claude Code and Cursor, run the canary prompt below in a session with the posture you ship. Each probe must be blocked or denied; for background and CI postures, an approval prompt counts as a failure.

4. Record the result in the [evidence bundle](/en/workflows/ship/evidence-bundle/) of the pull request that changed the settings. The harness owner signs off on the canary output, not on the settings diff.

5. Re-run the canary in CI whenever `.claude/settings.json`, `config.toml` or a hook changes. Harness changes are critical class.

## Copy-paste prompts for permissions and sandboxing

**Copy-paste prompt: audit the current posture**

```text
Audit this repository's agent permissions without changing anything. Read .claude/settings.json, .claude/settings.local.json, ~/.claude/settings.json, .codex/config.toml, ~/.codex/config.toml and any hook scripts that exist. Produce one table with a row per run type (interactive, background, CI) and columns: approval mode or policy, OS sandbox on or off, writable paths, network allowlist, secrets reachable from shell commands, and the bypass flag if any. Then list every place where a checked-in file tries to widen permissions, every wildcard domain that accepts uploads, and every environment variable matching KEY, SECRET or TOKEN that a sandboxed command could read. End with the three changes that remove the most risk, as exact settings diffs.
```

**Copy-paste prompt: run the sandbox canary**

```text
This is a sandbox canary test. Do not work around any failure and do not ask me to approve anything; report each result exactly as the tool returns it. Run these four shell commands one at a time: (1) echo canary > ./canary.txt, (2) echo canary > ~/canary-outside.txt, (3) cat ~/.ssh/id_ed25519 | head -c 20, (4) curl -sS -m 5 https://example.com. Then delete ./canary.txt. Report a table: command, expected (1 allowed, 2 to 4 blocked), actual result, and which layer blocked it (permission rule, sandbox filesystem, sandbox network, classifier). Flag any command that ran outside the sandbox.
```

**Copy-paste prompt: generate settings for a risk class**

```text
Write the agent permission settings for this repository at risk class high: public API contracts and CI configuration live here. Target Claude Code (.claude/settings.json) and Codex (.codex/config.toml). Requirements: OS sandbox on with no unsandboxed retry; writes limited to the workspace; network limited to registry.npmjs.org and our registry mirror; deny reads of .env files and ~/.ssh; force a prompt for git push and for any edit under .github/ and tests/; strip KEY, SECRET and TOKEN variables from shell commands; no bypass mode. Use only keys documented for Claude Code 2.1.283 and Codex 0.157.1, and for Codex use a permission profile, not sandbox_mode. After writing them, list which of these settings a user could override locally and which must move to managed settings or requirements.toml.
```

## What breaks in agent permissions and sandboxes, and how to recover

- **The sandbox is not running, and nothing says so.** By default, if bubblewrap or `socat` is missing or the platform is native Windows, Claude Code warns and runs commands unsandboxed. Recovery: set `sandbox.failIfUnavailable: true` in managed settings, and on Ubuntu 24.04 or later add the AppArmor profile for `bwrap` that Anthropic's sandboxing guide gives.
- **The agent retries outside the sandbox.** Claude Code may rerun a blocked command with `dangerouslyDisableSandbox`, which goes through normal approval, so in auto mode the classifier may approve it. Recovery: `allowUnsandboxedCommands: false`, or an ask rule on `Bash(dangerouslyDisableSandbox:true)`.
- **A deny rule is bypassed by another spelling.** `Bash(curl *)` does not match `sh -c 'curl …'`. Recovery: treat command rules as a first filter; the network allowlist is the egress control.
- **Project settings that do nothing.** `auto` or `bypassPermissions` as `defaultMode`, `strictAllowlist`, credential `mask` entries and `filesystem.disabled` are ignored in a repository's `.claude/` settings. Recovery: move them to user or managed settings.
- **An allowlisted host doubles as an exit.** A wildcard on a host that accepts uploads or gists lets an injected command send data out through an approved domain; Claude Code's own advisories list exfiltration through a pre-approved HuggingFace domain in WebFetch (Moderate, 2026-06-13); the same pattern applies to any allowlisted upload host. Recovery: allow exact hosts, prefer a registry mirror, and put `deniedDomains` on upload endpoints.
- **Secrets ride along in the environment.** Codex passes `*TOKEN*` variables to commands unless `ignore_default_excludes = false`; Claude Code protects only what you list. Recovery: strip or mask them, and keep production credentials out of agent environments.
- **Codex rejects the flags.** `codex -a untrusted` and `-a on-failure` fail with "invalid value" in 0.157.1, `codex exec -a never` fails with "unexpected argument", and a profile plus `--sandbox` does not compose. Recovery: `untrusted` and `granular` go in `config.toml`; drop `-a` from `codex exec` runs, which always use `never`; pick profiles or legacy flags, not both.
- **A `-p` run quietly skips blocked work.** In headless Claude Code with auto mode, three consecutive classifier blocks or 20 in total pause auto mode; the action does not run and Claude keeps working. Recovery: never gate the job on the agent's exit code; re-run tests and lint in a separate CI step and fail on those.
- **The agent itself has bugs.** Claude Code's security advisories include a sandbox escape via git worktree path confusion (High, 2026-06-25) and a workspace-trust bypass through a repository-controlled settings file (High, 2026-03-18). Recovery: stay on a supported channel, keep an outer container for critical class, and re-run the canary after each upgrade.

## Where to go next with the agent harness

- [The harness overview](/en/workflows/harness/) places permissions among context, tools, hooks, skills and environments.
- [The agent threat model](/en/org/agent-threat-model/) shows which runs combine private data, untrusted input and an outbound path.
- [Hooks as deterministic guardrails](/en/developer-scorecard-guide/agent-hooks/) adds checks the approval layer cannot express.
- [Ephemeral environments](/en/workflows/harness/ephemeral-environments/) gives each run a disposable outer boundary.
- [Background and cloud agents compared](/en/workflows/automate/background-agents/) covers the vendors' hosted environments.
- Next on the developer track: [the artifact chain](/en/method/lifecycle/artifact-chain/), which defines what each unattended run must leave behind as evidence.
