AI Newsway

832,378 Lines of Rust in 14.5 Weeks: Inside an Agent-Run Rewrite

The port cut memory use from 1,383MB to 126MB and cost roughly $120,000 in tokens โ€” and still shipped dozens of regressions the compiler happily approved

|5 min read0
AI Summary
GitHub rewrote the agent runtime behind Copilot from TypeScript into 832,378 lines of production Rust between May and August 2026, using coding agents supervised by primarily one developer across 128 pull requests. Throughput rose from 7.55 to 120 session lifecycles per second and memory fell from 1,383MB to 126MB. Dozens of regressions still shipped, showing the Rust compiler validates memory safety but not program correctness.
Source code on a developer's screen, the surface where GitHub's agents carried out a 14.5-week TypeScript-to-Rust port of the Copilot runtime
Source code on a developer's screen, the surface where GitHub's agents carried out a 14.5-week TypeScript-to-Rust port of the Copilot runtime

A production language runtime has been rebuilt in 832,378 lines of Rust, replacing TypeScript, and the performance delta is stark: a benchmark of 1,000 one-turn session lifecycles climbed from 7.55 per second to 120, while memory for a 10-client agent batch fell from 1,383MB to 126MB. The work ran from May 12 to August 21, 2026, was driven primarily by one developer supervising coding agents, and is documented in a detailed engineering write-up by Microsoft Distinguished Engineer Stephen Toub.

Key takeaways

  • Agents converted roughly 430,000 lines of production TypeScript into 832,378 lines of Rust across 128 merged pull requests over 14.5 weeks.
  • A benchmark running 1,000 one-turn session lifecycles went from 7.55 per second on TypeScript to 120 per second on in-process Rust, while a 10-client agent batch dropped from 1,383MB to 126MB of memory.
  • Of 31,247 user messages in the session logs, only about 2,600 were typed by a human โ€” roughly one in twelve.

The numbers behind the port

Alongside the production code, agents produced 468,689 lines of Rust unit tests. Port pull requests landed at about 1.3 per day while 135 public releases shipped around them, because modules were replaced in place rather than in one cutover. The Register reported the token bill at roughly $120,000.

Temporary scaffolding tells the same story: N-API exports bridging the two worlds peaked at 2,019 on August 3, alongside 3,356 TypeScript call sites. Both ended at zero.

What this runtime actually powers

The engine is invisible to most people who touch it. It backs the Copilot CLI, the Copilot desktop app, the Copilot SDK in six languages, and the cloud agent, and it ships inside recent releases of VS Code and Visual Studio. It also reaches into Excel, Outlook, PowerPoint and Word.

The original build ran TypeScript on Node.js with V8 โ€” fast to iterate on, but weak on startup latency and server density once the same engine had to be embedded through a C ABI in that many hosts. Toub was careful to bound the conclusion, writing that the project is in no way a claim that every large TypeScript program should become Rust, and that the requirements here emphasized C ABI embedding, low steady-state overhead and predictable resource use.

Why the agents spent more time reading than writing

The logs recorded 12,760,995 events and 1,857,409 tool starts. Git inspection commands alone consumed 608 measured hours. The prompt-cache hit rate reached 96.22%, without which sessions of that length would have been unaffordable.

The popular image of AI spewing code is almost backwards; at this scale, the work looked much more like iterative investigation.

The port of session.ts, a 30,000-line file touching every part of the runtime, took a 25-hour session that opened with 56 minutes of reading and 122 clarifying tool calls before a single edit. It then spawned 15 child sessions in seven waves and exchanged 89 coordination messages with them. Different models were assigned by strength, with GPT-5.6 Sol and Anthropic's Claude Opus 4.8 both used.

What the compiler could not catch

The borrow checker, the part of Rust that dominates every difficulty conversation, barely registered. Of 8,678 compiler errors, ownership, borrowing and lifetime issues accounted for 1.7%, while name and import resolution made up 37%. Unsafe code stayed contained at 158 blocks across 36 files, nearly all of it at C ABI, Windows API and POSIX boundaries.

The regressions were another matter. Dozens were traced, mostly surfacing in pre-release channels, and were not fully cleared until September 14. They clustered into incomplete migrations, state and lifetime issues, behavioural contract mismatches, host boundary problems and incorrect test oracles โ€” none of which a compiler evaluates. At RustConf in Montrรฉal, consultant Lisa Crossman warned against treating the compiler as an oracle, noting that Rust stops an agent from writing memory-unsafe code but not from writing the wrong program correctly. Toub reached a similar place, calling the idea that compiling code is correct code useful only as a joke.

Outlook

The comparison case is Bun, the Anthropic-owned JavaScript runtime, where creator Jarred Sumner moved roughly 535,000 lines of Zig to Rust almost entirely with Claude agents; the experimental port was passing 99.8% of Bun's tests on Linux x64 glibc by July 30, though stable builds still ship from Zig and Zig creator Andrew Kelley dismissed the output as unreviewed slop. GitHub took the opposite tack, replacing modules one-for-one without restructuring anything โ€” which means the actual optimization work has not started yet. The pattern echoes a similar two-engineer Rust rewrite at OpenAI: small human teams, enormous agent throughput, and review as the remaining bottleneck.

FAQ

Did AI agents write all of the Rust code?

Agents produced most of it, but humans stayed in the loop on design, review and final decisions. The session logs show roughly 2,600 human-typed messages against 31,247 total user messages, meaning a person intervened about once every twelve turns.

How much faster is the Rust runtime?

On one published benchmark measuring 1,000 one-turn session lifecycles with a shared client and 100 concurrent pipelines, the Rust build reached 120 lifecycles per second against 7.55 for TypeScript, a 15.9x gain. Memory for a 10-client agent batch fell from 1,383MB to 126MB.

Should other TypeScript projects migrate to Rust?

Toub explicitly declined to generalize. The case for Rust here rested on embedding through a C ABI, low startup cost and predictable resource use across many host applications โ€” requirements most TypeScript codebases do not have.

How do you feel about this article?

SJ

Discussion

Sign in to post
Loading...

Related articles

GitHub's HydraFusion Stops Picking a Model. It Builds a Workflow Instead.
Developer Tools

GitHub's HydraFusion Stops Picking a Model. It Builds a Workflow Instead.

GitHub's Project HydraFusion assembles a multi-model plan for every Copilot coding request, trading single-model simplicity for sharply lower cost.

Seung Jung6 days ago
Plugin4Shell: A Zero-Click RCE Hits Claude Code, Codex, Copilot and Gemini CLI
Developer Tools

Plugin4Shell: A Zero-Click RCE Hits Claude Code, Codex, Copilot and Gemini CLI

A zero-click RCE called Plugin4Shell bypasses the commit pinning AI coding agents use to keep plugins trustworthy. Two of four vendors have shipped a patch.

Seung Jung22 hours ago
Companies Are Now Licensing Their Private Source Code as AI Evaluation Data
Developer Tools

Companies Are Now Licensing Their Private Source Code as AI Evaluation Data

A consumer product with more than 200,000 users and a fintech platform that has processed over 100,000 bank statements have done something unusual with their pr...

Seung Jung4 days ago
Cloudflare Cut Astro's Open Issues by 85% With Four Agents That Refuse to Share Context
Developer Tools

Cloudflare Cut Astro's Open Issues by 85% With Four Agents That Refuse to Share Context

Separate reproduction, diagnosis, verification and fix agents hand off through a report file, with the original bug reporter acting as the acceptance test.

Seung Jung27 days ago
A Poisoned Rust Crate Was Live for 86 Minutes. It Had 245 Million Downloads.
Developer Tools

A Poisoned Rust Crate Was Live for 86 Minutes. It Had 245 Million Downloads.

Malicious releases of arrayref, internment and append-only-vec pulled an infostealer through a typosquatted proc-macro1 dependency during compilation.

Seung Jung27 days ago
Slack's New Channel Type Can Only Be Created by a Coding Agent
Developer Tools

Slack's New Channel Type Can Only Be Created by a Coding Agent

Slack Code launches with Claude, Devin, GitHub Copilot and Vercel. Agents open the channels, humans review or stop them, and archives serve as audit logs.

Seung Jung29 days ago