This post goes live on 28 November 2026.

§ Writing11 min read

Anthropic's Rust API passed 98% of its tests. A quarter of production inputs matched.

Anthropic's API migration shows how to compare two implementations without confusing model variance with a regression.

Anthropic’s Rust rewrite of its Messages API passed about 98% of its tests in April. On production traffic, only about a quarter of inputs matched the Python service it was replacing.

That gap comes from Anthropic’s 25 November account of the migration, and the way the team closed it has a detail I keep coming back to: they ran the model once, then replayed its output to the shadow implementation. Two different model responses never had the chance to look like an API regression.

The migration still needed to check inputs, streaming behaviour and usage accounting. Running the replacement alongside production could not be allowed to charge a customer twice or consume their limits twice. Those constraints change how I would build the verifier before asking an agent to fix a single mismatch.

This is design analysis with illustrative TypeScript. The figures below are Anthropic’s, not measurements I have reproduced. The gateway example and test plan are hypothetical; I haven’t run them.

What the tests missed

“Our Rust API passed about 98% of its tests in April, yet only about a quarter of inputs matched on production traffic.”

Anthropic, 25 November 2026.

Anthropic says its team started with about 700 integration tests, but those tests were coupled to the Python implementation and its in-process mocks. When the tests were ported along with the code, an audit found more than 100 weakened assertions. Passing the modified suite did not by itself establish that the two services behaved the same.

The company reports that the Rust API passed about 98% of its tests in April, while only about a quarter of compared production inputs matched. The article says what was compared changed over time and six misleading days were omitted from its chart. I would read the figures as evidence of a gap in this migration, not as comparable estimates of test coverage or a universal production mismatch rate.

One difference was JSON escaping: Python escaped some characters in tool calls, while Rust wrote them directly. The representations could be valid JSON yet produce different prompt bytes. If those bytes go to a model, I would not normalise the difference away merely because a JSON parser treats the strings as equivalent.

Anthropic describes the later result as roughly 70% less CPU per request and roughly 20% lower median time to first token. Its chart notes qualify those figures: CPU covers one region, while time to first token covers Claude Code customer requests over a shorter period. They are vendor-reported observations with different scopes, not a controlled promise that a Rust rewrite will produce the same gains elsewhere.

The running example: a gateway rewrite

Imagine an AI gateway moving its request handling from a Node service to a Rust service. The gateway resolves defaults, validates a tool schema, constructs a provider request, streams the reply and records usage. The old service remains authoritative while the team builds confidence in the replacement. This is an invented example, not a migration I have performed.

Both implementations can parse the same customer request, but only the old path is allowed to call the model, return the customer response and make the authoritative billing or quota mutation during shadowing. The new path receives a copy through a controlled internal seam. Its output goes to a comparator, not to the customer.

That arrangement needs enforcement, not a comment in the code. I would give the shadow process no live billing credentials and no direct route to a model provider. Stub or record every other mutating dependency, including audit writes, notification hooks and cache updates, according to what the test is trying to compare. If isolation cannot be established for a route, I would exclude that route and record the coverage gap rather than duplicate a real effect.

The single model call also has limits as a test. It makes the downstream replay comparable for one observed model stream. It does not compare two independent samples from the model or prove that a prompt difference has no effect on a future answer. That is why I would compare the constructed provider request before inference, then compare the two output paths against the same recorded stream.

The comparison contract

The contract needs to say where equality is exact, where a field can legitimately differ and which path has authority to cause an effect. I would write it before looking at the first mismatch.

Checkpoint Compare Treatment
Validation Acceptance, error category and relevant response fields Investigate a changed contract
Resolved settings Defaults, model route and feature flags Pin config and versions
Provider request Prompt bytes, tool definitions and inference settings Compare exact bytes where they reach inference
Model stream One authoritative sequence of chunks and terminal status Replay into the shadow parser
Client stream Ordered event types, payloads and terminal state Compare under a documented client contract
Usage intent Usage calculation and intended accounting action Compare without a second live mutation
Side effects Calls the shadow path attempted Fail if an unapproved effect escapes

This is my proposed contract, not Anthropic’s schema. It distinguishes byte-level parity from protocol-level parity. For example, if a client contract permits different network chunk boundaries but requires the same ordered events, the comparator can compare parsed events. If chunk boundaries themselves are observable and promised, it needs to preserve them. The team must decide that from the actual API contract rather than choosing whichever comparator makes the graph greener.

I would store the old and new build identifiers, policy and configuration revisions, checkpoint and comparison version with each result. Otherwise a new feature flag or an altered comparator can look like an improvement in the replacement. If the old service changes while the rewrite is underway, the target changes too. A passing result against last week’s build is evidence about last week’s build.

Compare without running the model twice

The sketch below describes data flowing through a verifier. It is not a complete implementation and does not make a shadow process safe by itself:

type StreamEvent =
  | { kind: "chunk"; bytes: Uint8Array }
  | { kind: "end" }
  | { kind: "error"; code: string };

type Comparison = {
  oldBuild: string;
  newBuild: string;
  checkpoint: string;
  outcome: "match" | "mismatch" | "not_compared";
  reason?: string;
};

declare function compareUnderContract(
  oldOutput: unknown,
  shadowOutput: unknown,
): Comparison;

async function compareReply(
  events: AsyncIterable<StreamEvent>,
  shadowParser: (events: AsyncIterable<StreamEvent>) => Promise<unknown>,
  authoritativeOutput: unknown,
): Promise<Comparison> {
  const shadowOutput = await shadowParser(events);
  return compareUnderContract(authoritativeOutput, shadowOutput);
}

compareUnderContract stands for the team’s versioned comparison rules. Production code would need bounded buffers, timeouts, cancellation, build metadata, backpressure and explicit error handling. The example does not implement any of those. In particular, the shadow path must not slow or change the customer’s authoritative response if it falls behind.

A replay should preserve the failure shape as well as happy-path text: partial chunks, provider errors, cancellations and terminal events. A model stream that ends halfway through a tool call is a different test from one that completes normally. A replay recorded after the fact can test a parser, but it cannot by itself demonstrate the timing or backpressure characteristics of the live path.

Anthropic says it compared steps before and after the model call and replayed the model output to Rust. That is a way to separate model nondeterminism from the API’s handling of an observed response. It is not a claim that the model is deterministic or that every customer-visible behaviour can be checked offline.

A useful mismatch without the message

Anthropic says its team could not read customer requests or replies while debugging the migration. Instead it recorded information about the shape of each difference, including the checkpoint, the part of the prompt, the first differing position and the lengths. A script grouped similar records, and an agent tried to reproduce each kind of discrepancy with its own synthetic request. Engineers reviewed proposed fixes before they crossed into the production-shadow loop.

I like the division of work. The production comparison tells the team where to look without handing an agent the original message. A synthetic reproducer gives the agent something it can inspect. A regression test can preserve the discovered behaviour after an engineer checks that the fix is appropriate.

The fingerprint is still data about a request. Positions, lengths, feature flags and repeated patterns can reveal information in some contexts, especially when joined with other logs. I would review the fields with privacy and security owners, minimise identifiers, restrict access, set retention limits and avoid raw text or high-cardinality labels in general metrics. Hashes are not automatically anonymous either, particularly for low-entropy values. Whether a given record is acceptable depends on the threat model and applicable data policy.

Fingerprints also group symptoms, not necessarily root causes. One bug can produce different fingerprints; an earlier difference can hide a later one. Anthropic reports both effects in its migration. A falling count of one fingerprint is useful, but I would also check total compared traffic, later checkpoints and new fingerprints before declaring the area fixed.

The oracle can be wrong

The old system is a practical reference, not a perfect specification. It may contain a security bug, an accidental quirk or behaviour the team intends to change. Reproducing that behaviour can make a new implementation faithfully wrong.

I would classify each mismatch as a candidate regression, a known reference defect, an intentional change, or unresolved. The last three require an owner and evidence. An intentional change needs a separate contract decision and tests; the comparator should not learn to ignore it simply because an agent edited the assertion. Where an old behaviour is unsafe, the team needs a migration plan that fixes or explicitly bounds it rather than silently copying it.

Anthropic gives an example of why matching alone was insufficient. An agent proposed copying a web-search tool description into files so the Rust prompt would match the Python prompt. An engineer rejected that shortcut because the replacement still needed to call the service supplying the description before launch. A local equality check passed, but the proposed change was not the desired production dependency.

That builds on my earlier post about review as a bottleneck. Here the question is narrower: what evidence reaches a reviewer, and what can a parity verifier actually establish? The reviewer needs to see the causal explanation and the intended long-term behaviour, not only a green diff.

Move from shadow to canary

A shadow result says something about the code path observed under the comparison setup. It does not show that customers can safely use the new service as the authoritative path. Before a cutover, I would test real ownership of billing, quotas, cancellation, provider failure and rollback in staging or another controlled environment.

Then I would use a small, time-limited canary with explicit stop conditions. Google’s SRE workbook describes comparing a canary deployment with a control to decide whether to proceed. For the gateway, I would watch contract errors, latency, stream termination and usage reconciliation by route and feature. A quiet canary is weak evidence if it has not seen the tool calls or cancellation cases that matter.

Report the denominator with the result: eligible requests, shadowed requests, successfully compared requests, excluded routes and reasons for failed comparisons. A dashboard showing “zero mismatches” when the comparator silently timed out is worse than an explicit not_compared. I would keep rare but consequential slices visible alongside the aggregate, and require an owner for each unresolved difference.

Rollback needs the same attention as rollout. If the new service has already made an authoritative mutation, sending a request back to the old path may not undo it. The team needs a source of record and an idempotency contract for each effect. As the Amazon Builders’ Library explains, a caller-provided identifier can express retry intent, but the receiving service must implement the contract. A request ID in a log alone does not prevent duplicate billing.

Tests I would write

  1. Send a request with non-ASCII tool arguments and assert that both paths build the expected provider bytes.
  2. Replay the same completed and interrupted model streams through both parsers and compare ordered events under the client contract.
  3. Remove live credentials and egress from the shadow process, then assert that attempted model, billing and quota mutations cannot reach production.
  4. Change a feature flag or reference build during a run and assert that the result records the changed version instead of mixing cohorts.
  5. Make the shadow parser stall or crash and assert that the customer response remains governed by the authoritative path and the comparison is marked incomplete.
  6. Introduce a known reference defect and assert that its exception has an owner and explicit expiry, rather than disappearing from the report.
  7. Simulate a timed-out accounting call and verify reconciliation against the accounting source of record before any retry.

These are proposed tests, not results. They are also not sufficient without representative traffic, permission to use it for comparison and a review of the telemetry that the verifier retains.

What I’d do on Monday

  1. List customer-visible contracts and every side effect of the authoritative request path.
  2. Give the shadow path an execution identity that cannot make live mutations or call the model.
  3. Define exact, semantic and intentionally excluded comparisons before measuring parity.
  4. Capture a single authoritative model stream for bounded replay and test cancellation and partial replies.
  5. Review fingerprint fields, access and retention with the teams responsible for customer data.
  6. Report mismatch and comparison-coverage denominators by build, configuration and feature slice.
  7. Require independent review, a canary and a tested rollback before making the replacement authoritative.

Limitations

This is design analysis. The TypeScript and tests are illustrative and unrun; I haven’t built this gateway or independently verified Anthropic’s migration results. The original article is a vendor account of its own system.

A parity check can reproduce an old defect, and its conclusion depends on the compared traffic, contract and isolation of side effects. The proposed controls do not by themselves establish privacy compliance, performance gains or safe exactly-once behaviour across distributed services.

Sources


  1. 10 min read

    OpenAI's Shirudo stopped an exploit without a restart. What else does the shield block?

    Shirudo can apply temporary protections to running Linux systems. The hard part is proving what to load, where, and when to remove it.


  2. 9 min read

    Upgraded to GPT-6.2? Your system prompt may now cost 20x more, and no error will tell you

    Since GPT-6.2, a system prompt sent in the instructions field is billed at full price on every call. Nothing breaks, so your alerts stay silent.


  3. 7 min read

    Perplexity needs a measurement contract

    OpenAI proposes perplexity as a shared progress metric. Compare scores only with their dataset, scorer, tokenizer and model stage attached.