techlist.io

Llm Classifier

1 posts

Anthropic2026-03-256 min readCurated summary

How we built Claude Code auto mode

Claude Code's default approval prompts lead to approval fatigue, and the existing alternatives both have serious drawbacks: sandboxing is safe but high-maintenance, and `--dangerously-skip-permissions` offers no protection. Auto mode sits between them. It replaces most human approvals with two model-based defenses, a prompt-injection probe on tool outputs and a transcript classifier that reviews each action before it runs. The classifier blocks about 99.6% of benign-looking traffic it would wrongly stop, but it misses roughly 17% of real overeager actions, so the author presents auto mode as a large safety improvement over skipping permissions, not a replacement for careful human review. ### The Problem with Approval Prompts - Users accept 93% of manual prompts, so approvals become rubber-stamping. - The authors' internal incident log includes an agent deleting remote git branches based on a misread instruction, uploading an engineer's GitHub token to an internal compute cluster, and attempting migrations against a production database. All came from a model being overeager, not malicious. - Sandboxing isolates tools but needs configuration for each new capability, and anything requiring network or host access breaks isolation. ### A Two-Layer Defense - **Input layer:** A server-side prompt-injection probe scans tool outputs (file reads, web fetches, shell output, external tool responses) before they enter the agent's context. If content looks like a hijack attempt, it adds a warning telling the agent to treat the content as suspect and stay anchored on the user's request. - **Output layer:** A transcript classifier running on Sonnet 4.6 evaluates each action before execution. It uses a fast single-token yes/no filter first and invokes chain-of-thought reasoning only when that filter flags the action. ### Threat Model The authors identify four reasons an agent might take a dangerous action: - **Overeager behavior:** The agent understands the goal but exceeds what the user authorized, such as using a credential it happened to find. - **Honest mistakes:** The agent misjudges the blast radius, such as treating a shared resource as test-scoped. - **Prompt injection:** Instructions planted in files or web pages redirect the agent toward an attacker's goal. - **Misaligned model:** The agent pursues its own goal. The authors say they don't see this in practice but evaluate for it on every release. Examples of blocked actions include: - Deleting remote branches after a vague "clean up old branches" request. - Grepping environment variables for alternative API tokens after an auth error. - Deleting a cluster job chosen by name similarity after "cancel my job." - Creating a public GitHub Gist with debugging code that may be confidential. - Retrying a failed deploy with a skip-verification flag. ### How Actions Are Permitted Actions pass through three tiers: - **Tier 1:** A fixed allowlist of read-only tools (file reads, search, code navigation, plan-mode transitions) plus user always-allow rules. On entering auto mode, broad rules that grant arbitrary code execution, such as blanket shell access, wildcarded interpreters like python or node, and package manager run commands, are dropped. Narrow rules like "allow running code formatters" carry over. - **Tier 2:** File writes inside the project directory skip the classifier, since they're reviewable through version control. - **Tier 3:** Everything else, including shell commands, web fetches, external integrations, subagent spawns, and filesystem operations outside the project, goes to the classifier. ### Classifier Decision Criteria The classifier prompt is a fixed template with three customizable slots. - **Fixed template:** Evaluates real-world impact rather than surface text. A payload written to a file and then executed is judged as the payload. A `&&` chain is one action. User intent is read conservatively: "clean up my branches" doesn't authorize a batch delete, and "can we fix this?" is a question, not a directive. - **Environment slot:** Defines what counts as trusted. By default, only the current git repo is trusted. Users can add their GitHub org, cloud buckets, or internal APIs. - **Block rules:** More than twenty default rules fall into four groups: destroying or exfiltrating data, degrading security posture (disabling logs, installing SSH keys or cronjobs), crossing trust boundaries (running code from external repos, scanning credential stores), and bypassing review on shared infrastructure. - **Allow exceptions:** Narrow carve-outs such as installing packages already declared in the repo's manifest or pushing to the session's working branch. Run `claude auto-mode defaults` to see the full baseline. The authors recommend editing it rather than starting from scratch. ### Results The evaluation used three datasets: 10,000 real internal tool calls, 52 real overeager actions, and 1,000 synthetic exfiltration attempts. | Stage | Real traffic FPR | Overeager FNR | Exfiltration FNR | |---|---|---|---| | Stage 1 only | 8.5% | 6.6% | 1.8% | | Full pipeline | 0.4% | 17% | 5.7% | When the classifier misses a dangerous action, it usually identifies the danger correctly. What it gets wrong is whether a consent signal in the session covers that action's blast radius. For example, "clean up the PR" doesn't name force-pushing, and one earlier approval isn't a pattern. The authors tried prompt engineering to fix this without success. ### Design Decisions - **Stripping assistant text and tool results:** The classifier sees only user messages and tool calls. This prevents the agent from rationalizing a bad action and blocks most prompt injection, since tool outputs are where hostile content enters. The cost is that the classifier can't always tell whether a resource was named by the user or fabricated by the agent. Including assistant messages reduced performance, and tool-calls-only lost the user-intent anchor. - **Two-stage classification:** Stage 1 is tuned to "err on the side of blocking" to maximize recall. Stage 2 uses the same prompt with a final instruction to reason carefully, which cuts false positives from 8.5% to 0.4%. Because the prompts are nearly identical, stage 2 is mostly cache hits. - **Layered injection defense:** An injection must evade the input probe, then steer the agent into a tool call the classifier independently judges as safe and aligned with user intent. - **Multi-agent checks:** The classifier reviews delegation (when the orchestrator spawns a subagent) and returned results (checking the subagent's full history), since a benign subagent can be compromised mid-run. - **Deny-and-continue:** A blocked action returns as a tool result asking the agent to find a safer path. After 3 consecutive or 20 total denials, the session escalates to the human. In headless mode (`claude -p`), the process terminates instead. A false positive therefore costs one retry rather than the whole session. ### Recommendation Auto mode is best suited to long-running tasks where manual approval overhead isn't worth the marginal safety gain. It isn't appropriate as a substitute for careful review on high-stakes infrastructure. Users should customize the classifier's environment and block rules for their setup, stay aware of residual risk, and report mistakes to the authors.