| 1 | # Auto-Review |
| 2 | |
| 3 | > 阅读简体中文版:[zh_hans/AUTO_REVIEW.md](zh_hans/AUTO_REVIEW.md)。 |
| 4 | |
| 5 | Auto-Review is the permission setting where Codewhale reviews each tool call |
| 6 | itself instead of asking you. Safe calls run, dangerous calls are blocked with |
| 7 | a reason, and uncertain calls go to a second model that judges that one call. |
| 8 | You are asked only for the few things that need a person. |
| 9 | |
| 10 | It is one stop on the permission dial described in |
| 11 | [Modes and permissions](MODES.md#permission-posture), and one layer of the |
| 12 | [authorization order](AUTHORIZATION_ORDER.md). It does not bypass tool |
| 13 | admission, repository rules or the [sandbox](SANDBOX.md). |
| 14 | |
| 15 | ## Turn it on |
| 16 | |
| 17 | - Press `Shift+Tab` until the footer shows Auto-Review, or run `/auto`. |
| 18 | - Or run `/config` and set the `permission_posture` row to `auto-review`. |
| 19 | - From the shell, start with `--permission-mode auto-review`. |
| 20 | |
| 21 | The internal value is `auto`; `approval_policy = "auto"` in config selects it. |
| 22 | |
| 23 | ## How a call is decided |
| 24 | |
| 25 | Two layers decide. The first is fixed rules; the second is a model. |
| 26 | |
| 27 | ### Layer 1: the deterministic floor |
| 28 | |
| 29 | The floor is your configured block rules plus a built-in safety floor. It is |
| 30 | never model-reviewed, and on unattended work it never waits for an approval |
| 31 | card. It does one of three things with a call. |
| 32 | |
| 33 | **Allows** calls it can prove safe. This includes explicit routine workspace |
| 34 | test and build commands, also with a trailing `2>&1` or `>/dev/null` and a |
| 35 | single `head`, `tail` or literal `grep` filter. It does not include |
| 36 | `cargo run`, non-routine `make` targets, `git add`, `git commit`, discard |
| 37 | flags, or anything your own block rules name. |
| 38 | |
| 39 | **Blocks** outright: |
| 40 | |
| 41 | - Package and release publishing: `npm publish`, `cargo publish`, |
| 42 | `gh release` and release tools. |
| 43 | - Destructive work in an unattended run (see |
| 44 | [Attended and unattended runs](#attended-and-unattended-runs)). |
| 45 | - Any repository push or tag change in an unattended run. |
| 46 | |
| 47 | **Holds** for the model reviewer, ahead of your `auto_review.allow` rules: |
| 48 | |
| 49 | - A push to a repository remote in an interactive session. |
| 50 | - The named soft rules: `force-push`, `git-tag`, `deploy-branch`, |
| 51 | `git-discard`, `infra-destroy`, `ci-or-pr-bypass`, `print-credentials`, |
| 52 | `secret-commit` and `deploy-wrapper`. The `print-credentials` rule includes |
| 53 | `.claude.json` and `.config/gh/hosts.yml`. |
| 54 | - Writes, edits, deletes or moves that target `AGENTS.md`, `CLAUDE.md` or a |
| 55 | loaded instruction file. |
| 56 | - File or shell writes that target a protected repository, credential, |
| 57 | IDE or agent, workflow, shell-startup or autostart path: `.git`, |
| 58 | `.codewhale/`, `.vscode/`, `.claude/`, `.mcp.json`, `.claude.json`, |
| 59 | `.github/workflows/`, `.gitconfig`, `.config/gh/hosts.yml`, shell rc and |
| 60 | profile files, `Library/LaunchAgents/`, `.config/autostart/`, |
| 61 | `.cargo/config.toml`, `.config/fish/`, `.config/systemd/user/` and the |
| 62 | Windows `Startup` folder, including symlink and path-alias targets. These |
| 63 | are held ahead of narrow allow rules and routine checks too. |
| 64 | - Outbound web requests, and any call the floor could not prove safe. |
| 65 | |
| 66 | Three more rules belong to the floor: |
| 67 | |
| 68 | - **Folders without git.** A bounded workspace write is treated as safe only |
| 69 | when local snapshots are enabled (`snapshots_enabled`) and the workspace |
| 70 | root is not `/`, a home folder or a top-level folder. Deleting a file or |
| 71 | emptying a whole file in such a folder still goes to the reviewer. The |
| 72 | Accept Edits rule for git work trees is unchanged. |
| 73 | - **First read outside the workspace.** The first shell read that resolves |
| 74 | outside the workspace asks you once per Auto-Review session when an |
| 75 | interactive owner can confirm it. Standard pseudo-devices such as |
| 76 | `/dev/null` do not count. An unattended run sends it to the reviewer |
| 77 | instead. The once-per-session state resets when you leave Auto-Review or |
| 78 | rewind or reset the session. |
| 79 | - **Critical-path deletions.** Deleting the filesystem root, the home folder, |
| 80 | the project root or any ancestor of it, or a `.git` folder asks you in an |
| 81 | interactive session and is refused in an unattended or headless one. |
| 82 | |
| 83 | ### Layer 2: the model reviewer |
| 84 | |
| 85 | A held call goes to a one-shot reviewer model. It returns a risk level, allow |
| 86 | or deny, and a reason. |
| 87 | |
| 88 | - **Which model.** `auto_review.reviewer_model` when set. Otherwise a capable |
| 89 | model on the session's active provider route when one matches, or the |
| 90 | session model. It never switches provider or account. |
| 91 | - **What it has.** No tools and no memory of earlier rules. It makes one |
| 92 | request and retries once after a timeout or transport failure, both inside |
| 93 | one 90-second budget. A review that still cannot finish (timeout, transport |
| 94 | failure, malformed or incomplete output, or context over budget) is a review |
| 95 | failure, not a safety denial: on an owner-present turn whose owner can be |
| 96 | prompted (not a child worker) it opens the normal approval card for that |
| 97 | exact call and is not counted as a block or an unavailable check; otherwise |
| 98 | the call is denied fail closed with a review-failure message. Cancellation |
| 99 | always fails closed. |
| 100 | - **High or critical risk** cannot run automatically unless you approve a |
| 101 | one-use retry of that exact call. An explicit denial by the reviewer still |
| 102 | blocks even then. |
| 103 | - **Soft-rule holds** carry the rule name in the hold, the block reason and |
| 104 | the receipt. They need an explicit request from you for that action, not a |
| 105 | broad instruction. |
| 106 | |
| 107 | The reviewer receives structured evidence, marked as untrusted, and nothing |
| 108 | else: |
| 109 | |
| 110 | | It receives | Notes | |
| 111 | | --- | --- | |
| 112 | | The exact `proposed_tool_call`, including its `description` | Never truncated. | |
| 113 | | Deterministic observations | Includes `person_approved_retry` and any triggering `soft_rule`. | |
| 114 | | `recent_actions` | Earlier non-read actions from the current turn, redacted. | |
| 115 | | `approved_plan` | When there is one. | |
| 116 | | `environment` | Scope entries from user or managed config. A project `.codewhale/config.toml` cannot set or change `auto_review.environment`. | |
| 117 | | `project_instructions` | Captured at session start with separate user and repository labels and SHA-256 hashes; never re-read from disk during the session. | |
| 118 | | `person_messages` | What the conversation owner typed, newest first. On a sub-agent turn these come from the root conversation, not from the child's brief. Empty on an agent-created background thread. On runtime threads the owner composer is the signed-in web client or a runtime-token caller that names `"client": "desktop"` (or `tui`/`web`) on the turn or steer request; other Runtime API callers record nothing. | |
| 119 | |
| 120 | It never receives attached `@file` bodies, skill instructions, expanded |
| 121 | context, tool outputs or assistant prose. |
| 122 | |
| 123 | The context is capped at 64 KiB. The current request and the exact proposed |
| 124 | call are never truncated; if they alone exceed the cap the review fails closed |
| 125 | as unavailable. Under pressure, repository instructions are trimmed first, |
| 126 | then user instructions, then the oldest middle `person_messages`, keeping the |
| 127 | earliest typed limit and the latest request. |
| 128 | |
| 129 | ## When a call is blocked |
| 130 | |
| 131 | Every block names the rule and the reason. Codewhale then either takes |
| 132 | another route or, in an interactive session with you present, offers a |
| 133 | one-use approval of that exact call: |
| 134 | |
| 135 | - run `/permissions blocked approve` (latest) or `/permissions blocked approve <receipt-id>`, or |
| 136 | - call the Runtime API: `POST /v1/threads/{id}/auto-review/approve`. |
| 137 | |
| 138 | A retry grant is bound to the exact `(tool_name, call_digest)`, is used up by |
| 139 | one retry, and still passes every other gate: hooks, typed permissions, |
| 140 | repository rules, the deterministic floor and the sandbox. It never extends to |
| 141 | sub-agents or plugin calls, and it is cleared when you leave Auto-Review or |
| 142 | reset the conversation. |
| 143 | |
| 144 | ## Repeated blocks |
| 145 | |
| 146 | | Run | Threshold | What happens | |
| 147 | | --- | --- | --- | |
| 148 | | You are present, and this is not a child worker | 3 blocks in a row, 20 blocks in the conversation, or 3 unavailable reviewer checks in a row | Permissions switch to Ask (`AutoReviewPaused`) and the work continues in Ask. Switching back to Auto-Review resets the counters. | |
| 149 | | Unattended | 20 blocks in total, or 10 unavailable reviewer checks in a row | The run never falls back to Ask. It continues past blocks and ends as interrupted with a summary of the blocked actions. | |
| 150 | |
| 151 | An allowed review resets the in-a-row block and unavailable counts. An |
| 152 | explicit denial by the reviewer resets the in-a-row unavailable count. |
| 153 | |
| 154 | ## Attended and unattended runs |
| 155 | |
| 156 | Each turn carries two facts minted by the engine. A host or a request field |
| 157 | cannot supply either. |
| 158 | |
| 159 | - **Run origin.** `Interactive` only when the turn was started or steered |
| 160 | directly from the owner's active terminal composer, or from a signed-in |
| 161 | owner runtime composer with an owner surface attached. `Headless` for `exec` |
| 162 | and ACP runs, including `approval_policy = "auto"`. `Background` for |
| 163 | detached starts, detached children, tasks, automations and delayed |
| 164 | `send_later` runs. |
| 165 | - **Owner presence** (`owner_present`). |
| 166 | |
| 167 | "Unattended" on this page means `Background`, `Headless`, or any turn where |
| 168 | `owner_present` is false. |
| 169 | |
| 170 | **When you are present.** Prompts that something else forces open the normal |
| 171 | approval card instead of being waived or failing closed: a typed |
| 172 | `permissions.toml` `ask` rule, a `tool_call_before` hook that answers `ask`, |
| 173 | prompt-only tools such as Computer Use consent and script cards, and |
| 174 | repository-rule holds that need a person. The exception is a hard block |
| 175 | (`hidden_unicode` or a configured `auto_review.block` rule). On a runtime |
| 176 | thread only the owner's surface (`desktop`, `tui` or `web`) may answer such a |
| 177 | card. |
| 178 | |
| 179 | **When you are not present.** No approval card is ever opened. A forced |
| 180 | prompt is refused, naming the rule, without registering a pending approval, |
| 181 | and a repository-rule hold that needs a person is blocked. |
| 182 | |
| 183 | **Headless `exec`** consults the model reviewer for non-destructive holds and |
| 184 | applies the deterministic unattended rules to destructive work. |
| 185 | |
| 186 | **ACP** turns use the deterministic rules only and refuse a call that only |
| 187 | the reviewer could decide. See [Runtime API: ACP stdio adapter](RUNTIME_API.md#acp-stdio-adapter-codewhale-serve---acp). |
| 188 | |
| 189 | **Plugin calls** that are held go to the reviewer with their host-minted |
| 190 | plugin identity. They are never cleared by routine tiers or allow rules. |
| 191 | Independent typed rules, hook holds and safety-floor blocks still apply. |
| 192 | |
| 193 | ## Questions to you |
| 194 | |
| 195 | Deliberate questions stay available in interactive sessions through |
| 196 | `request_user_input`. A question parks the turn until you answer or cancel it, |
| 197 | or its configured timeout expires. Headless `exec` withholds that tool because |
| 198 | nobody can answer. Tool safety holds are separate from these questions. |
| 199 | |
| 200 | ## Sub-agents and Fleet workers |
| 201 | |
| 202 | A worker under an Auto-Review parent follows the same policy: |
| 203 | |
| 204 | - Proven-safe calls run. Publish-like and destructive background work is |
| 205 | blocked. |
| 206 | - A hold it cannot prove safe goes to the same one-shot reviewer, using the |
| 207 | child's own session client. |
| 208 | - No prompt is ever opened for a child. An unavailable reviewer denies. |
| 209 | |
| 210 | When a child returns to an Auto-Review parent after running one or more tool |
| 211 | calls, the reviewer checks the child's list of executed actions once. It sees |
| 212 | tool names and compacted, redacted call inputs only, never tool results or the |
| 213 | child's report text, and compares them with the root owner's messages |
| 214 | (`person_messages`), the approved plan and the pinned project instructions. |
| 215 | If it flags a concern, or cannot run (unavailable, timed out, cancelled or |
| 216 | over the context budget), the engine puts a sanitized |
| 217 | `[Auto-Review warning: ...]` banner at the top of the report delivered to the |
| 218 | parent. |
| 219 | |
| 220 | Blocks from child calls and from return reviews are recorded in the parent's |
| 221 | blocked-actions list (`/permissions blocked` and |
| 222 | `GET /v1/threads/{id}/auto-review/blocks`) as `[sub-agent <id>]` entries. They |
| 223 | cannot be approved for retry (`approvable: false`). |
| 224 | |
| 225 | How children behave under the other permission settings is in |
| 226 | [Modes and permissions](MODES.md#children-sub-agents-and-fleet-workers). |
| 227 | |
| 228 | ## Configure it |
| 229 | |
| 230 | The `[auto_review]` table (allow and block rules, `reviewer_model`, |
| 231 | `environment`, `review_all_shell`, and the managed `disabled` switch) is |
| 232 | documented in [Configuration](CONFIGURATION.md). A project config file cannot |
| 233 | set it. |
| 234 | |
| 235 | ## Design references |
| 236 | |
| 237 | The LLM reviewer is closest to OpenAI Codex's experimental Auto-Review at |
| 238 | commit [`6fc6b9d6d2580d62622fc9884b5f5707f6505a5e`](https://github.com/openai/codex/tree/6fc6b9d6d2580d62622fc9884b5f5707f6505a5e). |
| 239 | Codex's [guardian entry point](https://github.com/openai/codex/blob/6fc6b9d6d2580d62622fc9884b5f5707f6505a5e/codex-rs/core/src/guardian/mod.rs) |
| 240 | reconstructs full conversation transcripts and runs a dedicated review session. |
| 241 | Codewhale passes only Rust-recorded owner `person_messages`, optional approved |
| 242 | plan text, redacted earlier non-read actions, session-pinned instructions, |
| 243 | deterministic observations, and the exact `proposed_tool_call` within a 64 KiB |
| 244 | cap, paired with a 90-second deadline, fail-closed result, and per-turn denial |
| 245 | circuit breaker. It excludes assistant prose and tool outputs and does not copy |
| 246 | Codex's transcript reconstruction, user-authorization score, reviewer tools, |
| 247 | retries, persistent review session, or denial ledger. |
| 248 | |
| 249 | Kimi Code at commit |
| 250 | [`1414d4602898f406e540b23342cb18db23ff9efc`](https://github.com/MoonshotAI/kimi-code/tree/1414d4602898f406e540b23342cb18db23ff9efc) |
| 251 | also has no LLM reviewer. Its ordered |
| 252 | [permission policy](https://github.com/MoonshotAI/kimi-code/blob/1414d4602898f406e540b23342cb18db23ff9efc/packages/agent-core-v2/src/agent/permissionPolicy/permissionPolicyService.ts) |
| 253 | applies explicit deny rules and then its |
| 254 | [Auto policy](https://github.com/MoonshotAI/kimi-code/blob/1414d4602898f406e540b23342cb18db23ff9efc/packages/agent-core-v2/src/agent/permissionPolicy/policies/auto-mode-approve.ts) |
| 255 | returns `approve` directly. Codewhale uses the deterministic floor and reviewer |
| 256 | described above, while keeping deliberate user questions available. |
| 257 | |
| 258 | The sandbox and escalation baseline is grounded in DeepSeek Harness |
| 259 | `0.1.0-rc.5` at |
| 260 | commit [`47f943859bef60e4160492346772ded9b24f765a`](https://github.com/deepseek-ai/deepseek-harness/tree/47f943859bef60e4160492346772ded9b24f765a): |
| 261 | its [sandbox contract](https://github.com/deepseek-ai/deepseek-harness/blob/47f943859bef60e4160492346772ded9b24f765a/docs/subsystems/sandbox.md) |
| 262 | defines per-call `read-only`, `workspace-write`, and `danger-full-access` |
| 263 | boundaries and forbids silent unconfined fallback; its |
| 264 | [approval contract](https://github.com/deepseek-ai/deepseek-harness/blob/47f943859bef60e4160492346772ded9b24f765a/docs/subsystems/approval.md) |
| 265 | grants only `allowed-once` and fails closed on rejection, cancellation, or an |
| 266 | unavailable answerer; and its |
| 267 | [sandbox result contract](https://github.com/deepseek-ai/deepseek-harness/blob/47f943859bef60e4160492346772ded9b24f765a/packages/shell/bash-sandbox/README.md) |
| 268 | tells the model to retry a denied command exactly once with the narrowest wider |
| 269 | mode plus a justification. DeepSeek Harness does not add an LLM reviewer to |
| 270 | that path. Codewhale's autonomous posture adds only the single stateless |
| 271 | reviewer request described above; deterministic hard blocks remain |
| 272 | non-bypassable in the reviewing postures. |
| 273 |