Microsoft Rewrites Copilot Runtime in Rust Using AI Agents for $120K
Tech

Microsoft Rewrites Copilot Runtime in Rust Using AI Agents for $120K

TechNews Editorial
TechNews EditorialSep 20, 2026 · 2 min read
Share

The software engine powering GitHub Copilot and other Microsoft products is now written entirely in Rust. AI agents completed the bulk of the porting work. The migration cost about $120,000 in AI token usage alongside three weeks of developer time. Managers also dealt with a few dozen code regressions. These issues highlighted ongoing challenges LLMs face in understanding Rust.

The project updated the runtime module by module until completion. This process spanned over 135 releases across a 14.5-week period. Roughly 1.3 port pull requests opened each day. Overall, agents converted 430,000 lines of TypeScript into 800,000 lines of production Rust. The port replaced TypeScript modules on a case-by-case basis without initially optimizing the runtime structure itself. That optimization work is next.

One benchmark measured how quickly the runtime completed 1,000 one-turn session lifecycles using a shared client and 100 concurrent pipelines. The original TypeScript implementation completed 7.55 of those lifecycles per second. Rust running in-process managed 120 per second. This represented a 15.9x speedup on that workload. Regarding memory, a 10-client batch of agents consumed 1,383 MB with TypeScript. The Rust rewrite consumed only 126 MB for the same swarm.

The Copilot runtime backs the GitHub Copilot command-line interface, the Copilot app, the SDK, and the GitHub Copilot cloud agent. It appears in VS Code, Visual Studio, Excel, Outlook, PowerPoint, and numerous Microsoft cloud services. Originally, the runtime used TypeScript with Node.js and V8. TypeScript and Node worked well for rapid development, but suffered at scale regarding start-up speed and server density.

Microsoft Distinguished Engineer Stephen Toub explained the process in a post. He noted the project used Copilot to rewrite Copilot. This effort utilized several LLMs including GPT-5.6 Sol and Claude Opus 4.8. Toub assessed the agents as largely successful. He noted the project would have taken years and cost millions if done by hand. Agents spent more time gathering information than writing code.

Toub observed surprising emergent behaviors during the migration. Sessions frequently interacted with other sessions they spawned or independent ones. One difficult conversion involved the session.ts file, spanning over 30,000 lines of TypeScript. That 25-hour conversion began with 56 minutes reading documentation and making 122 tool calls. It then spawned 15 child sessions, each creating a worktree and communicating with each other.

Toub also found hidden dangers in using Rust with LLMs. If code compiles, an LLM treats it as valid Rust. However, the project encountered dozens of code regressions. Consultant Lisa Crossman warned at RustConf against treating the compiler as an oracle. She stated that Rust prevents memory unsafe code but does not stop an agent from writing the wrong program correctly.

Toub found compiler-approved regressions stemmed from ambiguous semantics, branch drift, missing features, and differing behaviors. Toub noted that if-it-compiles-it-is-correct is only useful as a joke. Structural optimization of the runtime is the next known step.

Newsletter

Get the best AI & tech news daily

A concise daily digest. Unsubscribe anytime.

We use your email only to send this newsletter.

Related Stories