Microsoft used AI agents to fully port the GitHub Copilot runtime from TypeScript to Rust, which cost about $120,000 in token costs and a developer's three weeks of work.
This runtime is more critical than most users imagine: it powers GitHub Copilot CLI, Copilot App, SDK, and Copilot cloud Agent, and also appears in VS Code, Visual Studio, Excel, Outlook, PowerPoint, and a host of Microsoft cloud services. It originally used TypeScript with Node.js, which made development fast, but after scaling up, startup speed and server density became bottlenecks.
Performance Testing: From 7.55 per Second to 120, Memory Reduced by 90%
Microsoft Distinguished Engineer Stephen Toub wrote a detailed article about the entire process. The data shows that AI agents transformed 430,000 lines of TypeScript into 800,000 lines of production-grade Rust, spanning 135 releases and 14.5 weeks, with an average of 1.3 PRs opened daily for the migration. The main cost was tokens—about $120,000—with an additional three weeks of developer labor. Toub said that if done manually, it would have taken years and millions of dollars.
The performance gains are very real: in one benchmark test, the original TypeScript implementation handled 7.55 single-turn session lifecycles per second, while the Rust version ran 120 per second inside the process. In specific workloads, this achieved a 15.9x speedup. The memory usage difference was even more dramatic—one batch of 10 clients: TypeScript consumed 1383MB, while Rust only used 126MB, because the Rust version completed everything within the process, without needing to launch a background subprocess for completions like the TypeScript version did.
The "AI Spewing Code" Scene Is Almost the Opposite
Interestingly, this migration also demystifies "AI programming." Toub observed that the agents spent far more time gathering information than writing code itself. "The public image of AI wildly spewing code is almost the opposite; on this scale, the work looks more like iterative investigation—checking the current state, forming hypotheses, making targeted modifications, and looping."
The trickiest file was session.ts, a 30,000-line TypeScript file that touched all aspects of the runtime. Migrating it took 25 hours, with 56 minutes spent reading documentation and 122 tool calls to clarify requirements. Then it spawned 15 sub-sessions, each with its own worktree and agent, beginning to communicate with each other. A built-in orchestration skill found all active sessions and sent messages requesting collaboration for overlapping tasks.
However, this migration also exposed the pitfalls of using AI to write Rust: dozens of regressions appeared throughout the process—things that worked before now didn't. Toub summarized, "If passing the compiler means correctness, then that statement is only fit for a joke." The compiler doesn't know whether the function order is correct or whether the task cost is acceptable. At last week's Montreal RustConf, consultant Lisa Crossman also warned not to treat the compiler as a "oracle": "Rust prevents agents from writing unsafe code, but it doesn't stop them from writing correct yet wrong programs."
As a contrast, Bun author Jarred Sumner recently used Claude agents almost entirely to move Anthropic's JS runtime from 535,000 lines of Zig to Rust, costing $165,000 in tokens, and has passed 99.8% of existing Bun tests on Linux x64 glibc—but Zig creator Andrew Kelley still calls his code "garbage no one has reviewed." Along with this Copilot runtime migration, "AI-driven large-scale rewriting" is becoming a verifiable engineering reality: cheap, fast, but acceptance criteria must be monitored beyond just "compilation success" to ensure semantic correctness.



