deniz.in

Markets

Weather

Loading weather

· via Hacker News – Front Page (hnrss.org)

Microsoft ported the Copilot runtime to Rust with AI agents for about $120,000

The Register reports Microsoft converted 430,000 lines of TypeScript into Rust largely with AI agents for about $120,000 in tokens, gaining a 15.9x speedup on one benchmark but a few dozen regressions.

Microsoft ported the Copilot runtime to Rust with AI agents for about $120,000

The migration

Microsoft has rewritten the runtime that powers GitHub Copilot entirely in Rust, and according to The Register, AI agents did most of the porting work. The effort cost roughly $120,000 in AI token usage plus about three weeks of a developer's time. Microsoft Distinguished Engineer Stephen Toub, who documented the process, assessed the agent-driven approach as largely successful; The Register notes the same project done by hand would have taken years and cost millions.

The migration proceeded module by module, spanning more than 135 releases over 14.5 weeks at a pace of roughly 1.3 port pull requests per day. Agents converted 430,000 lines of TypeScript into 800,000 lines of production Rust. The port deliberately kept things simple: TypeScript modules were replaced one at a time on a case-by-case basis, without restructuring the runtime itself. That optimization work comes next.

The performance payoff

The Register cites one benchmark measuring how quickly the runtime completes 1,000 one-turn session lifecycles using a shared client and 100 concurrent pipelines. The original TypeScript implementation finished 7.55 lifecycles per second; Rust running in-process finished 120 per second, a 15.9x speedup on that workload. Memory tells a similar story: a 10-client batch of agents consumed 1,383 MB under TypeScript versus 126 MB under Rust. The Rust version also handled completion in-process rather than spawning external background processes, which TypeScript required.

Toub framed the decision narrowly, writing that the project is "in no way a claim that every large TypeScript program should become Rust." The team's requirements — embedding through a C ABI, low startup and steady-state overhead, and predictable resource use — are what pointed to Rust.

The runtime's reach extends well beyond GitHub: it backs the Copilot CLI, the Copilot app, the SDK and the GitHub Copilot cloud agent, and it surfaces in VS Code, Visual Studio, Excel, Outlook, PowerPoint and numerous other Microsoft cloud services.

How the agents behaved

Fittingly, the project used Copilot to rewrite Copilot, and it drew on several LLMs — Toub namechecked GPT-5.6 Sol and Claude Opus 4.8 — matched to tasks according to each model's strengths.

Toub described two behaviors that ran counter to expectations. First, agents spent far more time gathering information than writing code; at this scale the work resembled iterative investigation — inspecting the current state, forming a hypothesis, making a targeted change and repeating — rather than the common image of AI churning out code. Second, sessions frequently interacted with one another. The thorniest conversion, a session.ts file spanning more than 30,000 lines that touched all parts of the runtime, took a porting session 25 hours to complete. It opened with 56 minutes of documentation reading and 122 tool calls for clarification, then spawned 15 child sessions, each with its own worktree and agent. Using a built-in orchestration skill, one session identified other active sessions and messaged those with overlapping missions to request coordination.

Compiling is not correctness

The result was not clean. According to The Register, managers had to grapple with a few dozen regressions — things that worked before the port but not after. Toub traced these to ambiguous semantics and behaviors, branch drift, features that were never ported over, and behavioral differences in the replacement code. His blunt takeaway: treating "if it compiles, it's correct" as validation is useful only as a joke.

The Register places the project alongside a similar effort: Bun creator Jarred Sumner recently ported the Anthropic-owned JavaScript runtime and toolkit — roughly 535,000 lines of Zig — to Rust almost entirely with Claude agents, at a cost of $165,000 in tokens. As of July 30, the experimental Rust port was passing 99.8 percent of Bun's existing tests on Linux x64 glibc, while stable releases still ship from the Zig codebase. At RustConf in Montréal, consultant Lisa Crossman cautioned against treating the Rust compiler as an oracle, noting that Rust stops an agent from writing memory-unsafe code but "does not stop the agent writing the wrong program correctly."

Why it matters

This is one of the largest public data points on agentic code migration: a production runtime embedded across Microsoft's portfolio, rewritten for roughly $120,000 in tokens instead of a multi-year, multi-million-dollar manual effort. It demonstrates that agents can sustain a large, long-running refactor — reading, hypothesizing, coordinating and verifying over months. The regressions are the essential caveat: the Rust compiler guarantees memory safety, not semantic equivalence, so human review remains the only real check that a port behaves like the code it replaced. Any team considering a similar migration should budget for verification as heavily as for generation.

  • #microsoft
  • #copilot
  • #rust
  • #ai-agents
  • #typescript

Related posts