Microsoft has accomplished a seemingly paradoxical task: using artificial intelligence to rewrite the core runtime that powers its AI products. GitHub Copilot’s public runtime has been fully migrated from TypeScript to Rust, with the entire effort led by AI agents at a cost of roughly $120,000 in token expenses, plus three weeks of work from a single engineer.

Microsoft Distinguished Engineer Stephen Toub disclosed the full details of the project on the official GitHub blog. The effort spanned 14.5 weeks across 135 release versions, averaging 1.3 pull requests (PRs) per day for code porting. AI agents converted approximately 430,000 lines of TypeScript into more than 800,000 lines of production-grade Rust code. Toub stated bluntly in the post that a purely manual migration of equivalent scope would have required at least several years and millions of dollars.

This runtime is far from a peripheral component. It powers the GitHub Copilot command-line interface (CLI), the Copilot app, software development kits (SDKs), and Copilot cloud agents, and is embedded across Microsoft products including VS Code, Visual Studio, Excel, Outlook, and PowerPoint. The original architecture was built on TypeScript and Node.js—fast to develop against, but once deployed at scale it exposed bottlenecks in startup latency, memory consumption, and server density.

The post-migration performance numbers are striking. In one benchmark, the original TypeScript implementation handled 7.55 single-turn session lifecycles per second, while the Rust version achieved 120 per second in-process—a 15.9x speedup under specific workloads. Memory performance was equally impressive: running 10 agent clients, the TypeScript version consumed 1,383MB of RAM, while the Rust version needed just 126MB. A key reason is that the Rust implementation performs all computation in-process, eliminating the need to spawn background subprocesses for completion tasks that the TypeScript version required.

The demystification of AI coding

Toub offered a counterintuitive observation in his post: AI agents spend far more time gathering information than actually writing code. “The popular image of AI frantically spewing code is almost the opposite of reality; at this scale, the work looks more like iterative investigation—checking current state, forming a hypothesis, making one targeted change, then looping,” he wrote.

The most challenging file in the entire project was session.ts—a TypeScript file exceeding 30,000 lines that touches virtually every aspect of the runtime. Porting this single file took 25 hours, including 56 minutes spent reading documentation and 122 tool calls to clarify requirements. The AI agent then spawned 15 sub-sessions, each with its own worktree and agent, capable of communicating and collaborating with one another. A built-in orchestration skill was responsible for discovering all active sessions and sending collaboration requests to those with overlapping tasks.

Compiling successfully ≠ correct

This large-scale migration also exposed inherent flaws in AI-written Rust code. Dozens of regressions emerged throughout the process—features that previously worked correctly broke after modifications. Toub’s summary was pointed: “If compiling successfully meant the code was correct, that would only work as a punchline.”

The Rust compiler is highly effective at preventing memory safety issues and type errors, but it cannot judge whether code meets product requirements, whether it’s functionally equivalent to the original implementation, or whether performance and cost are reasonable. Even after successful compilation, issues can still arise: missing functionality, semantic ambiguities, inconsistent changes across branches, and behavioral differences between replacement implementations and the original.

Last week at RustConf in Montreal, consultant Lisa Crossman issued a similar warning. She cautioned developers against treating the compiler as an “oracle”: Rust can stop an agent from writing memory-unsafe code, but it cannot stop it from writing incorrect yet compilable programs.

Industry parallel: Bun’s Zig-to-Rust migration

Microsoft’s effort is not an isolated case. Jarred Sumner, creator of the JavaScript runtime Bun, recently relied almost entirely on Claude agents to migrate Anthropic’s JS runtime from 535,000 lines of Zig to Rust, at a token cost of approximately $165,000. On Linux x64 glibc platforms, the project has already passed 99.8% of Bun’s existing test suite.

But Zig creator Andrew Kelley isn’t buying it, still referring to the code as “unreviewed garbage.” The contrast highlights a broader reality: AI-driven large-scale code rewrites are becoming a verifiable engineering practice—low cost and fast, but acceptance criteria must be human-controlled for semantic correctness beyond mere compilation.

Toub concluded by emphasizing the value of AI agents in large migration projects: they can accomplish work at realistic cost and timelines that would previously have taken years. But he drew a clear boundary: AI-generated code that compiles absolutely does not equal correct code; requirements validation and quality assurance remain non-negotiable human responsibilities.