Menu
The Pragmatic Engineer·November 25, 2026

Anthropic's API Architecture Evolution: Python to Rust Migration and AI-Driven SRE

This article discusses Anthropic's architectural shift from a Python monolith to Rust for its critical Claude API, driven by performance and CPU footprint concerns. It also highlights their innovative use of AI agents for code review, on-call incident triage, and new engineer onboarding, showcasing how AI is reshaping software engineering practices and system operations.

Read original on The Pragmatic Engineer

The Need for a Rust Rewrite

Anthropic initially developed its Claude API as a Python monolith, which handled authentication, tokenization, billing, safety checks, and interactions with the GPU stack. This choice was pragmatic for a research-heavy company with a small team proficient in Python. However, as the API scaled, the CPU footprint of the Python monolith became a significant bottleneck. Despite optimization efforts within Python, the performance overhead remained substantial, especially in a context of global CPU shortages. This led to the strategic decision to rewrite the critical API serving all Claude tokens from Python to Rust, echoing a similar migration path observed at OpenAI.

Migration Strategy: Shadowing and AI Assistance

The migration to Rust was completed in approximately five months, even without a team of Rust experts. A key architectural decision for ensuring correctness and minimizing risk was employing a shadowing strategy. The new Rust API ran in parallel, processing production traffic and comparing its responses against the existing Python API. This allowed for iterative development and verification until responses were identical, acting as a "perfect test harness" without requiring strict human code reviews for every line of AI-generated Rust code.

💡

Shadowing for Safe Migrations

Shadowing is a powerful technique for rewriting critical services. By running the new service alongside the old one and comparing outputs, you can validate functionality and performance under real-world traffic without impacting users, significantly reducing deployment risk during large-scale refactorings or language migrations.

AI's Role in System Operations and Development

  • AI-driven Code Review: Anthropic utilizes a Claude agent to classify pull requests, determining if human review is necessary based on risk and change type. For mechanical or low-risk changes (e.g., SDK version bumps, fixing flaky tests), Claude can approve and even deploy autonomously.
  • Agentic On-Call: A Claude agent shadows the API on-call rotation, learning to categorize alerts as "real" or "noise" before escalating to a human. The long-term vision is for agents to handle incidents independently, moving towards an AI SRE model.
  • Onboarding and System Explanation: New engineers leverage Claude, connected to the codebase and internal systems, to understand architecture, generate interactive tutorials, and visualize system flows, replacing traditional onboarding buddies and documentation-heavy processes.
  • Tooling and Automation: Engineers are spending more time building internal tooling and multi-agent systems to accelerate their own work, indicating a shift towards engineering efficiency through sophisticated automation.

Organizational and Architectural Implications

Despite the advancements in AI, fundamental principles like two-pizza teams (5-8 people) remain crucial for managing complex systems and effective on-call rotations. This highlights the enduring importance of human-centric team structures alongside advanced automation. The company emphasizes project impact (e.g., CPU savings, latency reduction, incident avoidance) over time-to-completion for promotions, adapting evaluation metrics to the accelerated pace of AI-assisted development. This signals a shift in what defines engineering value in an AI-augmented environment.

PythonRustmonolithmigrationshadowingAISREcode review

Comments

Loading comments...