How Coding Agents Check Actions
How coding agents set up and restrict their environment lists the concepts six agents use for the workspace and its limits. This note follows one action through those limits: at which stage each check runs, what it looks at, and whether a rule decides or a model judges.
Sources
Read 2026-11-14.
- From source: Codex (
~/projects/common/codex, commitb1573f1024, paths undercodex-rs/), OpenCode 2.3.0 (~/projects/common/opencode, commitd759c548aa, paths underpackages/core/src/unless noted), Zoo Code (~/projects/common/Roomote/Zoo-Code, commitf2b4d1c0d), Cline (~/projects/common/cline, commit72b3d71405), Roomote 1.21.0 (~/projects/common/Roomote, commit6c8d4c3f0). - From official docs: Claude Code. The permissions, permission modes, sandboxing and hooks pages were only partly read verbatim; the rest came from summaries.
Paths are relative to each repository root. Line numbers will drift.
Stages
A tool call can meet checks at five stages:
- Tool list. Before the model sees its tools, some are removed: by deny rules, by the mode, or by a preset.
- At the call, before execution. Hooks, input checks, command parsing, rule matching, path checks, and then the approval decision: allow, deny, ask a person, or ask a reviewer model.
- During execution. The OS sandbox or container, the network proxy, the credential proxy, and timeouts.
- After execution. Output redaction and size limits, post-tool hooks, and commit hooks.
- Across the run. Loop detection, mistake counts, request and cost caps, and pauses after repeated denials.
Rules decide first in every agent. In the three agents that have a model-based check, the model judges only the actions that the rules leave open: an action the rules forbid never reaches it.
Deterministic and model-based checks
- Deterministic checks give the same answer for the same input: pattern rules, command parsers, fixed lists, path checks, counters, and OS enforcement. All six agents have them.
- Model-based checks ask a separate model to judge one planned action. Codex, Claude Code and Roomote have them. OpenCode, Zoo Code and Cline use no model to approve or deny an action.
Codex: the Guardian reviewer
- When it runs. When the approval policy is
on-requestorgranularandapprovals_reviewerisauto_review, or when admin requirements force it (ext/guardian-reviewer/src/routing.rs:59-67,core/src/guardian/decision.rs:108-115). It runs after hooks and only for actions that would otherwise go to the user (core/src/tools/approvals.rs:687-705). It can judge commands, patches, MCP calls, network hosts and requests for more permissions. - Setup. A separate sub-agent with read-only tools, approval policy
neverand no exec rules (core/src/guardian/review.rs:244-257). The model iscodex-auto-review, orgpt-5.6-lunawith an API key, falling back to the parent model at low effort (model-provider/src/provider.rs:98-100). - What it receives. The policy, the permission context, the transcript, retained user instructions, the reason for a retry, and the planned action as JSON. Its prompt opens “You are judging one planned coding-agent action.” It treats only user and developer messages,
AGENTS.mdfiles and answers to its questions as trusted; tool outputs, skills and assistant messages are untrusted evidence (prompts/templates/guardian/policy_template.md:1-12). - Decision. It assigns a risk level and the level of user authorization, then an outcome. Low and medium risk are allowed; high risk only when the user authorized it and the action is narrow; critical is always denied (
policy_template.md:66-75). - Failures. The default timeout is 90 seconds, with 3 attempts on parse errors and server errors. Other errors deny the action. Three denials in a row, or 10 of the last 50, interrupt the turn (
ext/guardian-reviewer/src/circuit_breaker.rs:3-7). - Asynchronous score. A second classifier scores actions
highorlowahead of time. A current low score lets the action skip the synchronous review (ext/guardian-v2/src/async_scorer/approval.rs:113-163).
Claude Code: the auto mode classifier
- When it runs. In
automode, after the rules. Read-only actions and edits in the working directory are approved without it; shell and network actions go to it. - What it receives. User messages, tool calls and
CLAUDE.md. Tool results are left out, so file or web content can’t steer it directly. - What it blocks by default. Piping curl to bash, sending sensitive data out, production deploys, force pushes,
git reset --hard, and turning off safety settings. Broad allow rules such asBash(*)are dropped on entering auto mode. - Failures. Three blocks in a row, or 20 in total, pause auto mode and return to asking. A classifier with no verdict blocks.
- It also reviews retries outside the sandbox in auto mode.
Roomote: the judgment model
- Integration tools in Auto mode. Only with the
integrationToolAutoApprovalsexperiment and the session owner’s opt-in (packages/cloud-agents/src/server/integration-tool-auto-evaluation.ts:790-817).- Code runs first. A credential-shaped argument always goes to a person, and an identifier never seen in the session marks the target as unverified (
:545-574). - The model (TypeSafe’s Jev, no general model allowed) answers scored questions: risk, whether the call only reads, whether it matches the request, whether the user authorized it, whether untrusted content steered it, whether it sends private data out (
:62-149). - Thresholds turn the scores into “run” or “ask”. The call runs only when the injection, exfiltration and guidance scores are all at most 0.2 and the call is routine, harmless or authorized (
:152-182,:381-437). - Without a judgment model the answer is “ask”. In a task with the owner away, “ask” becomes a denial with a reason (
packages/sdk/src/server/lib/task-tool-approvals.ts:567-615).
- Code runs first. A credential-shaped argument always goes to a person, and an identifier never seen in the session marks the target as unverified (
- Commits. A git hook runs
judgement check --stagedin each task checkout and judges the staged diff against the repository’s.judgement/rules.json(apps/worker/src/run-task/repository-judgement.ts:19-23,packages/types/src/judge-policy.ts:3-4). Without a rules file it passes with no model call.
A model’s own label
The Cline docs say the model marks each command with a requires_approval flag. In the source, the command tool run_commands has no such field (sdk/packages/core/src/extensions/tools/schemas.ts:127-176). The flag survives only in an unused error string. The VS Code extension approves commands from one setting, executeSafeCommands, off by default (apps/vscode/src/shared/AutoApprovalSettings.ts:30-43).
Codex lets the main model propose a prefix_rule or ask for escalation with a justification, but the decision stays with the rules, the reviewer or the user. A proposed rule is dropped if it is too broad: bare shells, interpreters with -c or -e, git, env, sudo, rm, npm run and others (core/src/exec_policy.rs:64-153).
Commands
After a sandbox blocks a command
- Codex detects a sandbox denial by exit code and error text (
sandboxing/src/denial.rs:13-72). Underuntrusted, or withgranularsandbox approval, it can retry outside the sandbox after a fresh approval; a reviewer approval doesn’t carry over to the retry. Underon-requestthe denial goes back to the model, which can rerun withrequire_escalated. - Claude Code retries outside the sandbox through
dangerouslyDisableSandbox, following the mode: a prompt by default, the classifier in auto mode, denied indontAsk.allowUnsandboxedCommands: falseturns retries off.
Prefix rules are not a boundary
The Claude Code docs say a Bash rule “isn’t a security boundary”: /usr/bin/curl or sh -c '...' get past Bash(curl *). In Zoo Code, a denied rm prefix doesn’t match sudo rm, env X=1 rm or /bin/rm. Codex matches only the executable when it isn’t the configured shell or in /bin or /usr/bin (core/src/exec_policy/executable_identity.rs:62-102). Only an OS sandbox holds against commands that a parser misreads.
Files
- Inside or outside the workspace.
- Codex checks every patch target, including move destinations, against the writable roots (
core/src/safety.rs:67-180). A patch inside them is approved and still written under the sandbox. - OpenCode asks for
external_directory, but resolves paths by text only, so a symlink inside the project that points outside counts as inside (file-access.ts:68-137). - Zoo Code marks a path as outside the workspace; the mark only changes whether it is approved automatically.
- Cline confines only relative paths and accepts any absolute path, and its tool schema asks the model for absolute paths (
sdk/packages/core/src/extensions/tools/editor.ts:28-65).
- Codex checks every patch target, including move destinations, against the writable roots (
- Protected files.
- Codex keeps
.git,.agents,.codexand.awsread-only inside writable roots, so a patch touching them asks (protocol/src/permissions.rs:50-61). - Zoo Code always asks before writing
.rooignore,.roomodes,.roorules*,.clinerules*,.roo/**,.vscode/**,*.code-workspace,.rooprotected,AGENTS.mdandAGENT.md(src/core/protect/RooProtectedController.ts:15-26). - OpenCode, Cline and Claude Code have no fixed list. Claude Code relies on
Editdeny rules.
- Codex keeps
- Ignore files.
- Zoo Code’s
.rooignoreblocks reads and edits. It blocks a command only when the command starts with a read command such ascat,greporsedand names an ignored file; chains aren’t split for this check (src/core/ignore/RooIgnoreController.ts:123-172). - Cline’s
.clineignoreisn’t enforced in the source; the controller is never created. The docs offer an example PreToolUse hook. - Claude Code has no ignore file. Its
ReadandEditrules also apply to file commands such ascat,head,sedand to redirect targets, but not to scripts that open files themselves.
- Zoo Code’s
.envfiles. OpenCode asks before reading*.envand*.env.*with the read tool, butgrepis checked on its pattern, so the rule doesn’t cover it. Roomote’s plugin refusesreadof.env*, but notcat .envthrough bash.- Per-role limits. Zoo Code’s
fileRegexlimits which files a mode may edit, tested against the raw path. OpenCode’s plan agent may edit only its plan folder. Cline’s Plan mode removes the edit tools. - Redirects. OpenCode treats a redirect target such as
> fileonly as part of the command text; it never checks it as a file write.
Network and integrations
- Codex sends traffic through its network proxy (
network-proxy/src/runtime.rs:898-938):- An explicit deny wins.
- Private and local addresses are blocked unless allowlisted.
- Limited mode allows only GET, HEAD and OPTIONS.
- Unknown hosts go to hooks, then the reviewer, then the user; an approval can’t override a deny or the local block.
require_escalatedbypasses the proxy.
- Claude Code sends sandboxed commands through a proxy with allowed and denied domains. A command that reaches an unknown host waits for a decision.
- OpenCode asks for
webfetchon the URL and checks each redirect against deny rules only. It has no block on private addresses (tool/plugin/webfetch.ts:71-167). - MCP tool approval.
- Codex has per-tool modes (
Auto,Prompt,Writes,Approve).Autorelies on the server’s read-only, destructive and open-world hints (core/src/mcp_tool_call.rs:2801-2829). - Zoo Code has per-tool
alwaysAllowlists and per-modeallowedMcpServers. - Roomote fingerprints each approved integration call. The API proxy consumes the approval, so one approval runs exactly one call (
packages/db/src/lib/integration-tool-approvals.ts:66-74,:218-233). Roomote showsreadOnlyHintto people but never uses it to decide. Tasks can’t make GitHub writes through MCP.
- Codex has per-tool modes (
Hooks
Every agent except Roomote lets a team add its own checks as hooks before a tool runs:
- Codex.
PreToolUsecan deny with a reason, or allow only together with a changed input; “ask” isn’t supported.PermissionRequestreturns allow or deny, and deny always wins (hooks/src/engine/output_parser.rs). - Claude Code.
PreToolUsereturns allow, deny, ask or defer. Deny and ask rules are still checked whatever the hook returns, so a hook can’t approve what a rule denies. Prompt and agent hook types let a team add its own model-based check. - OpenCode.
tool.execute.beforecan reject a call or change its input.permission.evaluatecan change any decision, including to allow; managed policy uses it to deny. - Zoo Code. No user hooks for tool calls.
- Cline.
PreToolUsecan cancel the run, add context or replace the input.- A returned
reviewvalue is parsed but never used. - Hook timeouts and errors let the call through (
sdk/packages/core/src/hooks/hook-file-hooks.ts:415-454,:577-606).
Limits on a run
Gaps visible in the source
- Zoo Code creates parent directories and an empty file while a write call is still streaming in, before the mode and
.rooignorechecks run (src/core/tools/WriteToFileTool.ts:194-255). - Cline’s SDK doesn’t pass the approval policy to sub-agents: approving the spawn approves everything the child does. Plan-mode hooks are inherited. The VS Code extension turns sub-agents off.
- Roomote’s tasks can still read the run token and
GH_TOKENfrom the shell; the plugin blocks only the obvious commands and redacts output. - OpenCode doesn’t resolve symlinks before its workspace check and doesn’t check redirect targets as writes.
Patterns
- Model-based checks sit behind rules. No agent lets a model override a deny rule. The model replaces the person for decisions the rules leave open.
- The reviewer is a separate model with a narrow view. Codex marks tool output as untrusted, and Claude Code leaves tool results out. Both try to keep the content an agent reads from steering the check on what it does. Roomote adds a scored question about whether untrusted content steered the call.
- Command parsing is the main deterministic technique, and the weakest point. The agents differ most in how they split a command and what they do with a command they can’t parse:
- Codex treats it as one unit.
- Claude Code asks.
- OpenCode refuses.
- Zoo Code reports an error.
- Built-in risky-command lists are short. Codex checks only forced
rm, OpenCode and Roomote have none, Zoo Code’s guard is off by default, and Cline’s list applies only in Plan mode. The protection against a harmful command comes from the sandbox or from a person. - Docs and source can disagree. Cline’s docs describe the
requires_approvalflag and.clineignoreenforcement, and the source has neither. Checks are worth reading in the source before relying on them.
Sources
- Codex:
codex-rs/core/src/exec_policy.rs,codex-rs/core/src/tools/orchestrator.rs,codex-rs/core/src/tools/approvals.rs,codex-rs/core/src/safety.rs,codex-rs/shell-command/src/,codex-rs/prompts/templates/guardian/,codex-rs/ext/guardian-reviewer/,codex-rs/network-proxy/,codex-rs/hooks/. - OpenCode:
packages/core/src/shell/scan.ts,packages/core/src/shell/parse.ts,packages/core/src/permission.ts,packages/core/src/file-access.ts,packages/core/src/tool/plugin/. - Zoo Code:
src/core/tools/ExecuteCommandTool.ts,src/core/auto-approval/,src/shared/parse-command.ts,src/services/destructive-command-guard/,src/core/ignore/RooIgnoreController.ts,src/core/protect/RooProtectedController.ts,src/core/tools/validateToolUse.ts. - Cline:
sdk/packages/core/src/extensions/tools/command-guard.ts,sdk/packages/core/src/extensions/tools/,sdk/packages/core/src/hooks/,sdk/packages/core/src/runtime/safety/loop-detection.ts,apps/vscode/src/sdk/sdk-tool-policies.ts,apps/vscode/src/shared/AutoApprovalSettings.ts. - Roomote:
apps/worker/src/run-task/opencode-tool-safety-plugin-script.ts,packages/cloud-agents/src/server/integration-tool-auto-evaluation.ts,packages/sdk/src/server/lib/task-tool-approvals.ts,apps/api/src/handlers/mcp/,apps/worker/src/run-task/repository-judgement.ts,packages/types/src/agent-safety.ts. - Claude Code docs: permissions, permission modes, sandboxing, hooks, security.