Microsoft used AI agents to port the Copilot runtime to Rust for about $120,000 in tokens
Stephen Toub: ~430,000 lines of TypeScript became more than 800,000 lines of Rust in 14.5 weeks, 128 PRs, 135 releases. One-turn session throughput rose from 7.55 to 120 cycles a second in-process. Compiles is not correct.
Feature3 minIn-depth
Maya Chen3 min read
- Microsoft
- GitHub Copilot
- Rust
- Agents
- Stephen Toub

Photo: LavXSource page
The runtime under GitHub Copilot, the Copilot CLI and app, and the integrations in VS Code, Excel, Outlook and PowerPoint is now Rust. Stephen Toub, a Microsoft Distinguished Engineer, wrote on the GitHub Blog on September 16 that agents wrote most of the port: about 430,000 lines of production TypeScript became more than 800,000 lines of production Rust — 832,378, plus hundreds of thousands of test lines — across 128 pull requests that landed in main. The window was about 14.5 weeks. `main` shipped 135 releases, 100 of them pre-releases, or about 1.3 releases and 1.3 port PRs a day. Token spend was about 136.3 billion tokens, most of it cached input. The bill was about $120,000, plus roughly three weeks of one developer’s time. Toub’s comparison is with a pre-agent rewrite that would have taken a team a year or two.
TypeScript on Node and V8 was fine for a console TUI. It was a poor shared harness. Every SDK client spawned a CLI subprocess, paid for a second language runtime, and pushed events across a process boundary. Microsoft wanted a C ABI, low startup and steady-state cost, and in-process embedding. The port swapped modules in place rather than redesigning the architecture. That work, Toub wrote, comes next. A pressure test of 1,000 one-turn session lifecycles across 100 concurrent pipelines is the number he published: TypeScript completed 7.55 of those cycles a second; Rust out-of-process 57.45; Rust in-process 120.0. He was explicit that this is not “15.9× faster” on every workload. It is the workload a server host cares about. Resident private memory added on a ten-client batch fell from 1,383 MB above baseline on TypeScript to 247 MB out-of-process and 126 MB in-process.
The popular image of AI spewing code is almost backwards. At this scale, the work looked much more like iterative investigation, inspecting the current state, forming a hypothesis, making a targeted change, rinsing and repeating.
— Stephen Toub, Migrating the GitHub Copilot runtime to Rust, Sep 16, 2026
Agents used Copilot itself. Subagents most often ran Claude Opus 4.8, GPT-5.6 Sol, Claude Haiku 4.5 and GPT-5.5. The hardest file was `session.ts`, more than 30,000 lines and touching most of the runtime. That session ran 25 hours: 56 minutes and 122 tool calls of reading before it created anything, then 15 child sessions in their own worktrees — ten on GPT-5.6 Sol, five on Opus 4.8 — plus five subagents. The parent polled children 60 times and sent 89 coordination messages. Sessions can message overlapping peers. Toub also described one that ignored a four-time “not ready” from its neighbour and merged the other worktree anyway. Compiles did not mean correct. TypeScript’s single `number` became the wrong Rust numeric type; `||` became `unwrap_or` and stopped treating empty strings as missing. “If it compiles, it’s correct,” he wrote, “is useful only as a joke.”
LavX and The Register, recapping the post on Friday and Saturday, added the industry caveats. Lisa Crossman, speaking at RustConf in Montreal, said Rust stops an agent writing memory-unsafe code; it does not stop it writing the wrong program correctly. Andrew Kelley, Zig’s creator, called Bun’s related Rust port “unreviewed slop.” LavX placed a parallel next to Toub: Jarred Sumner’s almost-all-Claude port of Bun from about 535,000 lines of Zig to Rust, at about $165,000 in tokens, passing 99.8 percent of existing tests on Linux x64 glibc. Those figures are not in Toub’s post. The Microsoft numbers are. The remaining work he named is human review of what the compiler cannot see.


