techlist.io

Anthropic/Python

5 posts

Anthropic2026-11-256 min readCurated summary

Migrating our Messages API to Rust

# Migrating the Claude Messages API from Python to Rust Using Production Traffic as the Verifier Anthropic migrated its Messages API from Python to Rust without taking the service offline or freezing feature work. The central problem was verification: Claude could write the new code in about a week, but there was no reliable definition of "correct" for a live system with undocumented customer behavior and a constantly changing Python baseline. The team turned production itself into an oracle, comparing the Rust and Python paths step by step on shadowed traffic, and used agents in layered verification loops to find and fix differences. The result was about 70% less CPU per request and roughly 20% lower median time to first token. ## Why a Full Rewrite - The Messages API began in 2023 as a thin Python request forwarder, but grew to validate, build prompts, tokenize, run safety classifiers, and parse streamed output, with each step adding Python overhead. - API traffic grew roughly 1,800x from early 2024 to fall 2026. - An incremental approach, moving only the output parser to Rust, cut CPU by 8 to 10%, but every token then crossed the Python/Rust boundary three times, adding overhead that offset the gains. - By May 2026, Claude wrote more than 80% of the code Anthropic merged, so generating the rewrite was no longer the bottleneck. Verifying it was. ## Why Existing Tests Were Not Enough - The team had about 700 integration tests, but they were coupled to the Python implementation: they ran the Python API in-process and mocked billing and rate limiting in Python memory. - Porting the tests introduced risk. An audit found more than 100 weakened assertions, so a passing test could hide wrong behavior. - The tests were incomplete. Twenty binary options alone yield over a million combinations, which would take about 12 days to run at one second each for a single model, before varying prompts. - Claude is nondeterministic, and it accepts nearly any prompt, so small prompt deviations often produce no error, just subtly different replies. ## Shadowing Production Traffic - Shadowing ran requests through both versions and compared results, but the usual assumptions did not hold. A request could not safely run twice, since it counted against customer limits and billing. Claude's nondeterminism meant outputs could differ legitimately. - The team ran the model once and replayed its output to the Rust path, so both versions worked from identical model output. They then compared every stage before and after the model call, requiring exact matches. - Customer requests and replies could not be read for privacy reasons, so the team recorded the shape of each difference rather than its content. - Initial results were sobering: the Rust API passed about 98% of its tests in April, yet only about a quarter of production inputs matched. Production also weighted bugs differently, since one common bug could trigger many mismatches. ## Two Techniques for Locating Differences - **Checkpointing:** Both versions pass each request through the same steps (accept or reject, resolve settings, build prompt). Comparing results step by step, and piece by piece within the prompt, pinpointed where the code diverged. - **Fingerprinting:** Each diff was summarized by where the first byte difference occurred and the length difference between versions. Bugs left consistent fingerprints across every request they affected, so errors could be grouped and triaged. - Each diff produced a small record, such as the step, the prompt piece, the first differing byte, and the fingerprint values for each version. ## Verification Loops - A script grouped the hundreds of thousands of near-identical diff records every 10 to 30 minutes by which fields differed. It alerted a coordinating agent only on new record types, which assigned a worker agent to each and opened a Slack thread for engineers to follow. - **Inner loop:** Agents ran in cloud sandboxes with both codebases and fast local checks. An input check built the prompts each version would send, without calling the model, in under a second. An output check ran both versions against a fake model with scripted replies. Agents hypothesized causes, reproduced them, and fixed the Rust until outputs matched, adding a regression test. Earlier, when agents had to wait for PR review and staging deployments, feedback took hours or days. - **Seam:** Fixes passed human PR review before moving to production. Engineers focused on questions verifiers could not answer, such as whether a difference was a bug or an intentional change. - **Outer loop:** Each fix was deployed and compared on shadowed production traffic, using request metadata such as model, caching, tools, and extended thinking to compare like with like. This caught cases the sandbox missed, since the local verifier was not configured exactly like production. - **Memory loop:** Reviewer decisions and agent lessons were saved as notes and rules that later agents read. One rejected shortcut for web search tool descriptions became a documented note, so agents later linked related records to the known bug instead of writing new workarounds. Other lessons became rules, such as porting Python's behavior exactly, and were encoded as tests, lints, and a merge check requiring matching Rust changes for Python edits. ## Lessons Learned - **Verification is the new bottleneck.** When writing code is cheap, the limiting factor is how quickly results can be verified, and ambition can scale as long as Claude has a reliable verifier. - **A production system can serve as a verifier** when formal proofs or tests are insufficient, but it rarely provides a useful failure signal by default. Much of the effort went into building one, through checkpoints and fingerprints. - **Verifiers can be gamed.** The web search shortcut matched outputs but was not a real fix, so human review remained an essential gate. - **Keep loops simple.** Humans defined what counted as correct, and agents chose hypotheses, reproductions, and fixes. Simple loops around strong verifiers scaled as Claude improved. - **Move engineers outward over time.** The team moved from working inside the inner loop, to steering at the seam, to writing the rules and checks agents operate within. The approach let the team build a new, equivalent service alongside the old one, shift traffic gradually, and keep both in step while the original kept changing.

Anthropic2026-01-215 min readCurated summary

Designing AI resistant technical evaluations

Tristan Hume, a lead on Anthropic's performance optimization team, describes how the take-home test he designed for performance engineer candidates has been repeatedly defeated by successive Claude models. Each redesign has bought only temporary separation between human candidates and the AI, and the post concludes that realistic work samples are becoming harder to build as models improve. Anthropic is releasing the original test as an open challenge, since with unlimited time the best humans still outperform Claude. ### Origins and Design Goals - In November 2023, Anthropic needed many more performance engineers to support new TPU, GPU, and Trainium clusters, but its standard interview pipeline could not keep up with the candidates it attracted. - The take-home was meant to be more engaging than typical take-homes, which tend to be generic and poor filters. It used a 4-hour window (later cut to 2 hours) to reflect the sustained focus of real engineering work and to leave time for understanding existing systems and building tooling. - Candidates were explicitly allowed to use AI assistance, on the reasoning that long-horizon problems remain harder for AI to solve completely. - The design followed general interview principles: representative of real work, high signal with a wide score distribution, no niche domain knowledge required, and fun. ### The Simulated Machine - The test used a Python simulator of a fake accelerator resembling a TPU, with a hot-reloading Perfetto trace showing every instruction. - Its features included manually managed scratchpad memory, VLIW bundles that require efficient instruction packing, SIMD vector operations, and multicore execution. - The task was a parallel tree traversal, inspired by branchless SIMD decision tree inference rather than deep learning. - Candidates started from a serial implementation and progressively added multicore parallelism, then SIMD or VLIW packing. Version 1 also included a bug to debug first, testing tooling skills. ### Early Success and Defeat by Claude Opus 4 - The first version worked well. One candidate from the Twitter outreach scored far above the rest, started in February 2024, and quickly found a workaround for a launch-blocking compiler bug involving 32-bit overflow in tensor indexing math. - Over about a year and a half, roughly 1,000 candidates took the test, and it helped hire most of the current performance team, including several undergraduates with limited resumes. - By May 2025, Claude 3.7 Sonnet could already outperform over half of candidates. Claude Opus 4 produced a more optimized solution than nearly all humans within 4 hours. - A previous live interview question had also been defeated by early Claude models, showing a recurring pattern. ### Version 2 and Defeat by Claude Opus 4.5 - Version 2 used Opus 4's failure points as its new starting point, with cleaner starter code, additional machine features for depth, and no multicore, which Claude had already mastered and which only slowed development loops. - The time limit dropped to 2 hours, partly because scheduling 4-hour sessions was causing multi-week pipeline delays. - Opus 4.5 worked for 2 hours, quickly reached the passing threshold, then stalled, convinced it had hit a memory bandwidth limit. When told the achievable cycle count, it found a trick that exploits the problem structure, and by the 2-hour mark matched the best human score, achieved by a candidate who had heavily used Claude 4. ### Options Considered and Failed Attempts - Banning AI was rejected because it is hard to enforce and because humans need to show skill in settings with AI, as they would on the job. - Raising the bar to "substantially outperform Claude Code alone" risked making the dominant strategy simply watching Claude work. - **Attempt 1:** A harder transposition problem with bank conflicts. Opus 4.5 found a transform-the-computation insight the author had missed, then solved the modified problem with extended thinking. The problem was too well represented in training data. - **Attempt 2:** Puzzles inspired by Zachtronics games, using a tiny constrained instruction set and minimizing instruction count. Opus 4.5 failed these. The starter code only checks validity, so building debugging tools is part of the evaluation. Early results correlate with candidates' past work, and one senior colleague scored higher than any candidate so far. The author acknowledges this sacrifices realism. ### The Open Challenge The original take-home is released publicly, starting from scratch but using version 2's instruction set so cycle counts are comparable. Benchmarks in simulated clock cycles: - 2164: Claude Opus 4 after many hours of test-time compute - 1790: Claude Opus 4.5 in a casual Claude Code session, roughly matching the best 2-hour human - 1579: Claude Opus 4.5 after 2 hours in Anthropic's harness - 1548: Claude Sonnet 4.5 after well over 2 hours - 1487: Claude Opus 4.5 after 11.5 hours in the harness - 1363: Claude Opus 4.5 in an improved harness after many hours Anyone who optimizes below 1487 cycles, beating Claude's best launch-time result, is invited to email performance-recruiting@anthropic.com with code and a resume. The post closes by noting that the current take-home is Claude-resistant for now, and that the author is curious how long it will last.

Anthropic2025-10-164 min readCurated summary

Equipping agents with Agent Skills

# Agent Skills: Packaging Procedural Knowledge for Agents Anthropic introduces Agent Skills, organized folders of instructions, scripts, and resources that agents can discover and load on demand to perform specialized tasks. The core argument is that as general-purpose agents gain access to full computing environments, they need a composable, scalable, and portable way to acquire domain expertise, rather than relying on fragmented, custom-built agents for each use case. Skills are published as an open standard and are supported across Claude.ai, Claude Code, the Claude Agent SDK, and the Claude Developer Platform. ## Anatomy of a Skill - At its simplest, a skill is a directory containing a `SKILL.md` file. - The file begins with YAML frontmatter that includes two required fields, `name` and `description`. - At startup, the agent preloads the name and description of every installed skill into its system prompt, so it knows when each skill applies without loading the full content. - If a skill seems relevant, Claude reads the full `SKILL.md` into context. - Complex skills can bundle additional files (for example, `reference.md` or `forms.md`) that `SKILL.md` references by name. Claude loads these only when needed. - The PDF skill used as the example keeps form-filling instructions in a separate file, so the core skill stays lean. ## Progressive Disclosure - Skills load information in levels: metadata first, then the core instructions, then linked files as needed. This works like a manual with a table of contents, chapters, and an appendix. - Agents with filesystem and code execution access don't need to load an entire skill into context, so the amount of material a skill can contain is effectively unbounded. ## Skills and the Context Window - The context starts with the system prompt, the metadata for installed skills, and the user's message. - When a request matches a skill, Claude uses a Bash tool to read that skill's `SKILL.md`. - Claude then decides whether to read any bundled files, such as `forms.md`, before completing the task. ## Executable Code in Skills - Skills can include scripts that Claude runs as tools. - Code suits operations that LLMs handle poorly or expensively, such as sorting or deterministic processing. Running a script is also consistent and repeatable. - The PDF skill includes a Python script that extracts form fields from a PDF. Claude can run it without loading the script or the PDF into context. ## Developing and Evaluating Skills - **Start with evaluation:** Run agents on representative tasks, find where they struggle, and build skills to close those gaps incrementally. - **Structure for scale:** Split large `SKILL.md` files into referenced files, keep rarely combined paths separate to save tokens, and make clear whether scripts should be executed or read. - **Think from Claude's perspective:** Observe how Claude uses skills in practice. The `name` and `description` fields matter most, since Claude uses them to decide whether to trigger a skill. - **Iterate with Claude:** Have Claude capture successful approaches and common mistakes into the skill, and ask it to self-reflect when it goes off track. ## Security Considerations - Malicious skills can introduce vulnerabilities or direct Claude to exfiltrate data or take unintended actions. - Install skills only from trusted sources. For less-trusted skills, audit bundled files, especially dependencies, scripts, and instructions that connect to external networks. ## Looking Ahead - Anthropic plans to add features covering the full skill lifecycle: creating, editing, discovering, sharing, and using skills. - Skills may complement Model Context Protocol (MCP) servers by teaching agents multi-step workflows that involve external tools. - The longer-term goal is for agents to create, edit, and evaluate their own skills, codifying their behavior into reusable capabilities. Skills are intentionally simple in concept and format, which makes it easier for organizations, developers, and end users to build customized agents. Developers can start with the Skills docs and cookbook.

Anthropic2025-06-263 min readCurated summary

Desktop Extensions: One-click MCP installs

# Desktop Extensions: One-Click Installation for Local MCP Servers Anthropic is introducing Desktop Extensions, a packaging format that bundles a local MCP server and all its dependencies into a single `.mcpb` file that installs with one click. The change addresses the friction that kept powerful local MCP servers out of reach for non-technical users, who previously needed developer tools, hand-edited configuration files, and manual dependency management. The format is open-sourced and versioned as 0.1, with a curated extension directory and enterprise controls built into Claude Desktop. ## Problems with Manual MCP Installation - Users needed Node.js, Python, or other runtimes installed beforehand - Each server required manually editing `claude_desktop_config.json` - Dependency conflicts and version mismatches had to be resolved by hand - Finding useful servers meant searching GitHub - Updating a server meant reinstalling it manually ## How Desktop Extensions Work A Desktop Extension is a ZIP archive with the `.mcpb` extension. The only required file is `manifest.json`, which describes the extension's metadata, features, user configuration, and runtime requirements. The archive typically also contains the server code and bundled dependencies, such as a `server/` directory with an entry point and a `node_modules/` or `lib/` directory for Python packages. - **Built-in runtime:** Claude Desktop ships with Node.js, so no external runtime is needed - **Automatic updates:** Extensions update when new versions are available - **Secure secrets:** Sensitive values such as API keys are stored in the OS keychain - **Configuration gating:** Claude won't enable an extension until required user settings are supplied - **Variable substitution:** Placeholders like `${user_config.api_key}`, `${__dirname}`, `${HOME}`, and `${TEMP}` are resolved at launch - **Platform overrides:** The `platforms` block lets developers set different commands or environment variables for Windows and macOS ## Manifest and Packaging - The manifest declares user configuration fields with types, defaults, validation rules, and a `sensitive` flag - Configuration can be passed to the server as environment variables or command-line arguments - Developers can declare tools and prompts up front so users see capabilities before installing - The `npx @anthropic-ai/mcpb init` command generates a manifest interactively, and `npx @anthropic-ai/mcpb pack` validates it and produces the archive - Users can test a package by dragging the `.mcpb` file into Claude Desktop's Settings window ## Ecosystem and Enterprise Controls Anthropic is open-sourcing the MCPB specification, packaging and validation tools, reference implementations, and TypeScript types and schemas. The goal is for the format to work across other AI desktop applications, so developers can package a server once. For enterprises, Desktop Extensions support Group Policy on Windows and MDM on macOS, pre-installation of approved extensions, blocklists by extension or publisher, disabling the extension directory, and private extension directories. Users can audit installed extensions. ## Practical Takeaway MCP server developers can package an existing server by running `npm install -g @anthropic-ai/mcpb`, then `mcpb init` and `mcpb pack`. Anthropic also notes that Claude Code can build extensions with little intervention when given the MCPB specification links and a short description of the desired behavior. Internally, the team has used the format to package experimental servers, including one that lets Claude play a GameBoy game through the PyBoy emulator.

Anthropic2025-01-064 min readCurated summary

Claude SWE-Bench performance

The upgraded Claude 3.5 Sonnet scored 49% on SWE-bench Verified, beating the previous state-of-the-art of 45%. The authors achieved this with a deliberately minimal agent: one prompt and two general-purpose tools, with as much control as possible left to the model. They argue that tool design and scaffolding matter as much as the model itself, since SWE-bench measures the whole agent rather than the model alone. ## Measuring Agents with SWE-bench - SWE-bench tests whether a model can resolve real GitHub issues from popular open-source Python repositories. The model receives a configured environment and a checkout of the repository from just before the fix, then must understand, modify, and test the code. - Solutions are graded against the unit tests from the pull request that originally closed the issue. - The benchmark is attractive for several reasons: it uses real engineering tasks rather than competition-style questions, it is not saturated (no model had crossed 50% on SWE-bench Verified), and it evaluates a full agent, so open-source developers can improve scores by optimizing scaffolding around the same model. - The authors use SWE-bench Verified, a 500-task subset that humans reviewed to remove tasks that cannot be solved from the issue text alone, such as those requiring specific error messages not stated in the issue. ## A Minimal Tool-Using Agent - The agent consists of a prompt, a Bash tool for running shell commands, and an edit tool for viewing, creating, and editing files and directories. - The model is sampled repeatedly until it decides it is finished or exceeds its 200k-token context window. There are no hardcoded workflow stages. - The prompt suggests an approach (explore the repo, write a reproduction script, edit the source, rerun, consider edge cases) without being overly long or prescriptive. The authors note that explicitly encouraging long responses can help when token cost is not a concern. ## Tool Design and Error-Proofing - Tool descriptions were tested and revised to预empt misunderstandings. For example, the Bash tool description specifies that commands need not be XML-escaped, that there is no internet access, and how to run long-lived commands in the background. - The edit tool requires absolute paths. This prevents errors when the agent has moved away from the repository root. - Of the edit strategies tested, exact string replacement was the most reliable. The model specifies `old_str` and `new_str`, and the replacement happens only if `old_str` matches exactly once. Otherwise, the model receives an error and can retry. - The edit tool also supports `view` (with optional line ranges), `create`, `insert`, and `undo_edit`. ## Results | Model | SWE-bench Verified | |---|---| | Claude 3.5 Sonnet (new) | 49% | | Previous SOTA | 45% | | Claude 3.5 Sonnet (old) | 33% | | Claude 3 Opus | 22% | - All models were run with the same agent scaffold. - Compared with older models, the upgraded Claude 3.5 Sonnet self-corrects more often and tries several different solutions instead of repeating the same mistake. ## Example Agent Trajectory - The example is a scikit-learn issue in which `RidgeClassifierCV` rejects a `store_cv_values` argument, even though its attributes depend on that parameter. - The model first viewed the repository structure, then wrote and ran a script that reproduced the `TypeError`. - It then identified that the subclass constructor did not forward `store_cv_values` to the base class, edited the constructor to accept and pass the parameter, and reran the script. - The task was solved in 12 steps. Other tasks took over 100 turns, and some runs ran out of context. ## Challenges in Running SWE-bench - **Cost and duration:** Successful runs sometimes took hundreds of turns and more than 100k tokens. The model is persistent, which is effective but expensive. - **Grading errors:** Some apparent failures were caused by environment setup issues or install patches applied twice, not by the model. - **Hidden tests:** The model cannot see the grading tests, so it may believe it succeeded when it has not. Some solutions were applied at the wrong level of abstraction, such as a bandage rather than a deeper refactor. Others were correct but did not match the original unit tests. - **Multimodal limits:** The agent could not view image files saved to disk or referenced by URL, which made Matplotlib tasks especially hard and led to hallucinations. The authors identify this as an opportunity for improvement. The post closes by noting that developers building with the upgraded model will likely find better ways to improve SWE-bench scores than those demonstrated here.