🤖 AI Hot

GitHub Rewrote Copilot's Runtime in Rust Using Copilot

A
Alex Chen

Any list of the best AI tools 2026 is going to have GitHub Copilot near the top, but the most interesting story about Copilot this month is not a new feature — it is what the company did to the tool itself. Between May and August 2026, a single developer used Copilot’s own agent capabilities to rewrite the entire Copilot agent runtime from TypeScript into Rust: 832,378 lines of production Rust, plus 468,689 lines of Rust unit tests, landed in 128 pull requests and shipped incrementally to real users the whole way. A rewrite that would have taken a whole team a year or two before agents was completed primarily by one person in a few months. This is the clearest case study yet of what agentic coding actually does at scale, and it deserves a careful look from anyone trying to figure out how much of their own codebase an AI can migrate.

The post, published on the GitHub engineering blog under the title “Migrating the GitHub Copilot runtime to Rust, using Copilot,” is unusually honest about both the wins and the pain. I will walk through why they did it, how they did it, and what the process reveals about where AI coding agents are genuinely useful — and where they still need a human holding the wheel.

Why the runtime needed to change

The Copilot agent runtime is the shared engine behind a surprising amount of software. It backs the GitHub Copilot CLI, the GitHub Copilot app, and the Copilot SDK, but it also underlies the latest releases of VS Code, Visual Studio, the Copilot cloud agent, Copilot Code Review, Copilot Cowork, Copilot Studio, and the Copilot integrations across Excel, Outlook, PowerPoint, and Word. All of these very different products want the same intelligence, security, reliability, and performance — and they want a fix in one place to fix all of them.

The problem was the language the runtime was written in. It was originally built in TypeScript on Node.js, running on the V8 JavaScript engine. That was a reasonable choice for the CLI’s terminal UI, where rapid development matters and startup overhead is tolerable. But as the runtime became an embedded component of half a dozen products, the costs compounded. The SDK had been layered on top of the CLI rather than the other way around, so creating a new client meant spawning a whole CLI subprocess — launching Node and V8, parsing the compiled JavaScript, paying for V8’s memory footprint, and marshaling every call across a process boundary through a JSON-RPC mechanism.

The consequence was that every SDK consumer, in every language, shipped a second language runtime it had no other use for — on the order of 100 MB of working set per client, at minimum. A crash in Node took the whole session down. Anyone deploying this had at least two processes to supervise and debug. For an SDK meant to be embedded in C#, Python, Go, Java, and Rust applications, that was untenable.

The team wanted a runtime that could be embedded in-process through a C ABI, with minimal dependencies, predictable resource use, and a modern security posture. Rust was the obvious answer — not because every TypeScript program should become Rust, but because Rust’s strengths mapped exactly onto the requirements: low startup and steady-state overhead, clean FFI interop across six SDK languages, and a toolchain with less supply-chain risk.

The scale of the rewrite

The numbers tell the story better than adjectives can. In early May 2026, the initial estimate put the runtime at roughly 130,000 lines of TypeScript. That estimate was, as the author puts it, “wildly misleading” in two directions. First, code that had been tangled up in the TUI layer kept getting pushed down into the runtime as the port progressed. Second, the repo was absorbing hundreds of new pull requests a week from other agentically assisted developers, constantly adding new TypeScript faster than the port could remove it.

By the end, approximately 430,000 lines of production TypeScript passed through the port. During the same window, the runtime took in about 300,000 production lines of TypeScript and shed about 430,000, while roughly 1,200,000 production lines of Rust entered and 365,000 left. The chart in the post shows the dramatic visual: TypeScript falling to zero while production Rust climbs past 830,000 lines and Rust unit tests climb to nearly 469,000. The apparent stability of the TypeScript line for most of the project was hiding enormous churn underneath.

The final state, as of August 21, was 100% production Rust: 832,378 lines of production Rust, 468,689 lines of Rust unit tests, and 174,675 lines of end-to-end TypeScript tests retained to validate the port. The execution runtime that was entirely TypeScript in May was entirely Rust by August — and it shipped to users continuously, not as one terrifying cutover.

In-place porting, not a big-bang rewrite

The strategy is the most transferable part of the post. Rather than freezing the codebase and rewriting it in a parallel branch, the team ported in place, component by component, bottom-up. They merged each piece into main as it was ready, so the runtime was always a working, shippable whole. This is the opposite of the classic rewrite-from-scratch failure mode, where a team disappears for a year and emerges with a branch that has diverged so far it can never merge.

Porting in place also meant the work was continuously validated against a moving target. The few regressions that did surface — mostly around Rust’s explicit lifetimes and shared state, which TypeScript developers do not have to think about — were found and fixed quickly, because the blast radius of any single change was small. The author is candid that the lifecycle regressions were a real cost of choosing Rust, and that the team had to learn to represent shared state explicitly. That is the honest trade nobody should gloss over: Rust buys you performance and safety, and charges you in borrow-checker friction.

The AI agent framework comparison that actually matters

The most instructive part of the post is the review loop, because it is a working example of how to run multiple AI coding models against each other on a single, high-stakes codebase. The workflow the author describes is a genuine AI agent framework comparison, lived rather than theorized: for the trickiest components, a parent agent would rebase a port onto the latest main, then launch one review subagent per model — Claude Opus 5, GPT-5.6 Sol, and Grok 4.6 — each doing a line-by-line comparison of the old TypeScript and the new Rust to confirm behavioral equality.

The review instructions were exacting. Each subagent had to flag anything introducing an incompatibility, push for idiomatic Rust, call out defunct TypeScript that had not been deleted, and treat any remaining non-shim TypeScript as a red flag. If a review surfaced issues, the parent would validate them, fix them, and run the full review again until all three models came back clean. This is the pattern that matters: not “which model is best” in the abstract, but “use several frontier models as adversarial reviewers against each other, and let a human arbitrate.” The models catch each other’s blind spots, and the human makes the final call on anything questionable.

The orchestration was equally revealing. Porting the session.ts component — effectively the top layer of the runtime — involved a 25-hour parent session that spawned five subagents and fifteen child sessions across seven waves. Each child session worked in its own worktree to isolate its changes, while the parent acted as an information broker, polling the children sixty times and sending eighty-nine coordination messages, then cherry-picking and reconciling their commits. The parent did the coordination work; the children did the diff-producing work.

The accidental build-scheduling discovery

The single most practical lesson in the post is one the author learned the hard way. At one point, all fifteen concurrent agents on a single laptop each tried to build and test simultaneously, and the machine ground to a halt. The fix was to turn a plain chat session into a build scheduler — what the author calls “an agentic mutex.” The prompt was almost embarrassingly simple: every open session had to avoid CPU-intensive builds, ask the gate session for permission when a build was necessary, and accept that only one session could build at a time.

Sessions that asked for and were denied the build lease would wait by doing other work, like picking items off a todo list. It is a small detail, but it captures something important about agent orchestration that the industry is only starting to internalize: when you run many agents in parallel, the bottleneck stops being intelligence and becomes shared resources. CPU, memory, and disk are the new coordination problems. Anyone running more than a handful of coding agents should take the mutex pattern seriously.

What actually got better

The performance headline is that the runtime improved “by orders of magnitude,” which is the kind of vague claim that usually signals hand-waving but is believable here given the architecture change. Moving from out-of-process JSON-RPC calls to a spawned Node process, to in-process native calls through a C ABI, eliminates the dominant cost of the old design: process startup, V8 warm-up, memory overhead, and cross-process serialization. For an SDK that gets embedded in other applications, that is not a marginal improvement — it is a different product.

For the six Copilot SDK language front-ends, the change means no more shipping a second language runtime. A Rust application embedding Copilot no longer drags Node and V8 along with it. The runtime is a pure native binary exposing a C ABI for in-process consumption, with a stdin/stdout or socket-based server available for the cases where out-of-process is still desirable.

Limitations and caveats

This is a success story, but it is worth reading the fine print before you conclude that agents can rewrite your codebase too.

The author is explicit that this does not mean “every large TypeScript program should become Rust.” The choice was driven by specific requirements — embedding through a C ABI, low overhead, predictable resource use — that do not apply to a typical web service. The right target language varies by application, and a lot of teams would be making a mistake to chase the Rust rewrite as a default.

The process was also far from hands-off. A single developer drove it, but that developer spent months coordinating agents, writing review prompts, resolving conflicts, and debugging lifecycle regressions. The agents wrote most of the code, but the human was doing real architectural work throughout. This is agent-assisted engineering, not agent-replaced engineering.

Finally, the multi-model review loop worked because the stakes were high enough to justify running three frontier models against every contentious component. That is expensive, and it is only worth it when a behavioral-equality bug is costly — as it is in a runtime that powers a widely deployed product. For lower-stakes migrations, the same rigor would be overkill.

The bottom line

The Copilot Rust migration is the best public evidence yet that agentic coding changes the economics of large-scale rewrites. The specific numbers — 832,000 lines of Rust, 128 pull requests, one developer, a few months — give a concrete data point where most discussions of “AI will replace programmers” are still hand-waving. But the more durable lessons are in the process: port in place, use multiple models as adversarial reviewers, isolate parallel agents in separate worktrees, and gate shared resources with a mutex. Those patterns will outlast any single model or language.

Sources

Disclosure: CarCare Guide is reader-supported. When you buy through links on our site, we may earn an affiliate commission at no extra cost to you. Learn more.
A
Alex Chen