Ant Engineer reverse-engineers Claude code source, revealing the four-layer decision pipeline mechanism of Auto Mode

Gate News, March 25 — Ant Group engineer and Umi.js front-end framework author Chen Cheng reverse-engineered the source code of Claude Code 2.1.81, fully restoring the decision mechanism of Auto Mode. The key finding: each tool invocation passes through four layers of decision-making, and only when the first three layers cannot determine the outcome will an independent AI classifier be called for safety review.

The four layers of the pipeline are: first, checking existing permission rules; if matched, allow directly; second, simulating acceptEdits mode (permission level allowing file edits). If it passes in this mode, it indicates low risk, and the classifier is skipped; third, checking the read-only tool whitelist (Read, Grep, Glob, LSP, WebSearch, etc.), which do not modify any state and are unconditionally allowed; only if none of these conditions are met does it proceed to the fourth layer, sending an API request to Claude Sonnet for safety classification.

Key design details of the classifier include: always using Sonnet instead of Opus, balancing cost and latency; setting temperature to 0 to ensure deterministic output; the classifier is defined as a “safety monitor for autonomous AI programming agents,” protecting against three types of risks (prompt injection, scope creep, unintended harm); the user’s CLAUDE.md configuration file is injected into the classifier context as the basis for judging user intent.

The interception rules cover over 22 categories, including force push, direct push to main branch, downloading and executing external code, production deployment, data leaks, self-modification permissions, creating remote code execution surfaces, credential leaks, etc. Exceptions for allowing include seven types: hardcoded test keys, local file operations within the working directory, read-only GET requests, installing declared dependencies, official toolchain installations, reading configuration credentials sent to target providers, and pushing to the current working branch.

The system also implements a circuit breaker mechanism: after three consecutive rejections or a total of 20 rejections, the system downgrades to manual confirmation; in headless mode, it directly aborts the agent. When the classifier is unavailable, a feature flag controls whether it “fail-closed” (immediately reject) or “fail-open” (downgrade to manual confirmation).

In Auto Mode, prompt injection behavior is finely controlled: injected once every five dialogue rounds, with the first injection in each five-round cycle being the full version (about 800 words, including six instructions such as “execute immediately,” “reduce interruptions,” “action over plan”), and the remaining four being a concise one-line version, balancing context window usage and behavioral stability.

Disclaimer: The information on this page may come from third parties and does not represent the views or opinions of Gate. The content displayed on this page is for reference only and does not constitute any financial, investment, or legal advice. Gate does not guarantee the accuracy or completeness of the information and shall not be liable for any losses arising from the use of this information. Virtual asset investments carry high risks and are subject to significant price volatility. You may lose all of your invested principal. Please fully understand the relevant risks and make prudent decisions based on your own financial situation and risk tolerance. For details, please refer to Disclaimer.

Related Articles

Fireblocks' 30 Web3 Partners Manage Over $200B in Monthly Stablecoin Flows

Gate News message, April 26 — Fireblocks, a leading institutional-grade asset transfer platform, operates a network of 30 Web3 business partners spanning DeFi protocols, payment settlement, compliance analysis, trading institutions, and multi-chain infrastructure. The partnership ecosystem is

GateNews14h ago

Moore Threads Q1 Revenue Surges 155% YoY to $104M, Swings to Profitability

Gate News message, April 26 — Moore Threads reported first-quarter 2026 revenue of 738 million yuan (approximately $104 million), representing a 155.35% year-over-year increase. The company swung to profitability with net income of 29.36 million yuan, compared to a loss of 112 million yuan in the sa

GateNews15h ago

Stablecoins aren’t just for cross-border payments—they’re for going local too! a16z’s latest report: Asia supports two-thirds of transaction volume

Crypto VC giant a16z’s latest report, “9 charts on what stablecoins are becoming,” uses nine key charts to depict the structural changes underway in stablecoins. The report’s central takeaway is not new tokens or new narratives, but stablecoins’ role shifting from “trading tools” and “savings vehicles” to “core financial infrastructure,” along with an increasingly strong degree of localization—creating a clear gap between what the market originally expected and the reality of cross-border payments. **GENIUS Act in the U.S. boosts stablecoin trading volume to $4.5 trillion in Q4** For years, regulatory uncertainty has been the ceiling for institutional participation in stablecoins. The turning point came from the U.S. GENIUS Act establishing the first federal-level stablecoin issuance framework. a16z data shows that, prior to the bill’s passage, the adjusted stablecoin trading volume had already been rising for several consecutive quarters.

ChainNewsAbmedia16h ago

Central Bank of Brazil: Stablecoins Dominate Over $6.9 Billion Crypto Purchases Registered in Q1

According to data released by the Central Bank of Brazil, stablecoin purchases comprised $6.8 billion of the $6.9 billion in cryptocurrency purchased abroad by Brazilians during Q1. This represents an increase of over 100% compared to the same period last year. Key Takeaways: Brazil’s Central Ban

Coinpedia18h ago

Stablecoins Emerging as Core Financial Infrastructure, Localization Trends Accelerate: a16z Report

Gate News message, April 26 — According to a report from a16z crypto researchers Robert Hackett and Jeremy Zhang, stablecoins are evolving from early-stage trading instruments and savings vehicles into core financial infrastructure. The U.S. GENIUS Act has

GateNews04-26 00:02

79% of Global Crypto ATMs Located in United States

Gate News message, April 25 — According to Cointelegraph, 79% of crypto ATMs worldwide are located in the United States.

GateNews04-25 16:03
Comment
0/400
No comments