GitHub Copilot Runtime Rust Rewrite Explained: 832,378 Lines, One Engineer and a Team of Agents (World Tech)
Image: GitHub Blog — official architecture diagram from "Migrating the GitHub Copilot runtime to Rust, using Copilot" (before: every SDK launched the CLI as a separate Node.js process; after: SDKs host the Rust runtime in-process or out-of-process).
📌 KEY HIGHLIGHTS
- What moved: the Copilot agent runtime — the shared engine behind Copilot CLI, the Copilot app, the Copilot SDK, VS Code, Visual Studio and Copilot features in Excel, Outlook, PowerPoint and Word — from TypeScript on Node.js to Rust.
- How big: about 430,000 lines of production TypeScript passed through the port; the finish, on 21 August 2026, was 832,378 lines of production Rust plus 468,689 lines of Rust unit tests.
- How fast: GitHub's benchmarks show 3.0–5.9x faster out-of-process and 6.3–21.4x faster in-process than the TypeScript baseline, with model inference excluded — and in-process mode is still opt-in.
- What it cost: about $120,000 in tokens (roughly 136.3 billion tokens, 96.22% prompt-cache hit rate) and, by lead engineer Stephen Toub's own estimate, about three weeks of his time.
- The honest catch: the compiler did not catch everything — dozens of regressions slipped through and were fixed, and the "one engineer" headline leaves out teammates who built the SDK bindings, the interop layer and the reviews.
What happened?
This post is an explainer of GitHub's own engineering account, published on 16 September 2026 (updated 23 September) by Microsoft Distinguished Engineer Stephen Toub — a post developers are still dissecting a month later because it is one of the most concretely documented agent-driven rewrites ever published. The Copilot agent runtime is the harness that runs sessions, tools, MCP servers and model calls. It started as the engine of a terminal UI: TypeScript on Node.js and the V8 engine. That was a fine choice for a console app — and a poor choice for a component meant to be embedded by other programs.
When GitHub needed an SDK, it layered the SDK on top of the CLI: the CLI gained a headless mode, and SDKs in C#, Python, Go, Java and Rust spawned the CLI as a child process and talked to it over JSON-RPC. Every SDK consumer therefore shipped a second language runtime — on the order of 100 MB of working set minimum — for an engine its application otherwise had no use for. Every event, message and session file-system read crossed a process boundary, a crash in Node took the session with it, and every deployment had at least two processes to supervise.
GitHub Copilot runtime Rust rewrite explained: why Rust, and how it was done
GitHub wanted a runtime with minimal dependencies, fast startup, predictable memory use, and a shape every SDK language could load in-process through its foreign-function interface — plus a modern security posture with less supply-chain risk. Rust met those requirements, and Toub is explicit that this is not a claim every large TypeScript program should become Rust. The target language, he writes, legitimately varies from application to application.
The port was done in place, not as a big-bang rewrite. Each pull request replaced one TypeScript component with a thin shim calling into Rust and deleted the old code in the same change, while a temporary interop layer let the two languages coexist. The main branch stayed shippable throughout: all end-to-end tests across the CLI and SDKs ran against the new Rust code at every step, and a pull request that broke a required test did not land. The team kept shipping during the port — 135 releases (35 stable, 100 pre-release) — even as tens of agentically assisted developers kept merging hundreds of pull requests a week into the same codebase, which is why the initial estimate of roughly 130,000 lines of TypeScript turned into roughly 430,000 lines actually passing through the port.
Image: GitHub Blog — official performance chart from the migration post (benchmarks through the C# SDK; model inference and network latency excluded).
The numbers: what 14.5 weeks actually produced
GitHub benchmarked through the C# SDK against a deterministic chat server on localhost, so model inference and network latency are not part of these numbers. Toub also stresses that the speedups compare shipped systems, not languages in isolation.
| Scenario | TypeScript baseline | Rust, out-of-process | Rust, in-process |
|---|---|---|---|
| Client, session, one turn | 5.25 s | 1.33 s (4.0x) | 292 ms (18.0x) |
| Resume a 32-turn session | 5.64 s | 1.52 s (3.7x) | 264 ms (21.4x) |
| Ten concurrent client lifecycles | 12.34 s | 4.18 s (3.0x) | 742 ms (16.6x) |
| 1,000 one-turn session lifecycles | 132.52 s | 22.53 s (5.9x) | 20.93 s (6.3x) |
| Memory added by ten concurrent clients | 1,383 MB | 247 MB | 126 MB |
The review system is the part other teams are copying. Reviewer agents on three different models (Claude Opus 5, GPT-5.6 Sol and Grok 4.6) compared the old TypeScript with the new Rust line by line, under a rule that no end-to-end test could be deleted or changed — a changed test was treated as evidence of a porting bug. Copilot's own agents handled 61% of the roughly 1.13 million tool calls the project required. And the compiler was not an infallibility oracle: it flagged 8,678 errors along the way, but only 1.7% involved ownership, borrowing or lifetimes, and dozens of regressions still reached main and had to be fixed. The rule Toub set for the port was "translate first, redesign second."
Why it matters for India readers
India has one of the world's largest developer populations, and Copilot is a daily tool for many of them. The direct wins land first for people who build on the SDK or live in the CLI: faster startup on modest laptops, far less memory on shared CI runners, and no Node.js sidecar to install and supervise. Indian startups building developer tools can now embed the runtime in C#, Python, Go, Java or Rust apps through the SDK without shipping a second runtime at all. The wider signal matters too: this is the clearest public evidence yet of what agent-assisted migration costs in practice — about $120,000 in tokens and a few weeks of one senior engineer's time for a project Toub estimates would previously have taken a whole team a year or two — and of what it does not replace: an engineer who understands the system well enough to set guardrails, challenge the agents and vouch for the result. It does not make Copilot's answers better; the models are untouched. What changed is the plumbing underneath them.
Should you care?
FAQs
Why did GitHub rewrite Copilot's runtime in Rust? Because the TypeScript runtime ran on Node.js, so every SDK client in six languages had to launch the Copilot CLI as a separate process and talk to it over JSON-RPC, paying roughly 100 MB of working-set overhead per client. GitHub wanted a native runtime all six SDKs could load in-process through a C ABI, with minimal dependencies and predictable resource use.
How much faster is the Rust Copilot runtime? In GitHub's benchmarks through the C# SDK, 3x to 6x faster out-of-process and 6x to 21x faster in-process than the TypeScript baseline, depending on the scenario — for example, a client session with one turn fell from 5.25 seconds to 292 milliseconds in-process. Model inference and network latency were excluded, and in-process mode is opt-in.
Did AI really write the Rust code for Copilot? Mostly, under supervision. Copilot agents wrote most of the 832,378 lines of production Rust and handled 61% of about 1.13 million tool calls, across 128 pull requests. Stephen Toub drove the port and estimates it took about three weeks of his own time, while teammates built the SDK bindings, the temporary interop layer, packaging and reviews.
Should I rewrite my TypeScript app in Rust? Not on this evidence alone. GitHub says explicitly that its requirements — embedding through a C ABI, low startup and steady-state overhead, predictable resource use — pointed to Rust, and that the right target language varies by application. For most apps, the lesson to copy is the method: small in-place ports, tests that cannot be weakened, and agent reviewers comparing old against new.
Takeaway: Copilot rewrote its own engine in Rust, in public, with receipts — 832,378 lines, 128 pull requests, startup cut from seconds to milliseconds. The code is the headline; the review system and the honesty about regressions are the part worth stealing.
Follow World Tech on TechByCountry for tomorrow's 6 PM update.
📸 Get tech in the last 24 hours on Instagram — follow @_techinlast24hrs for daily posts (9 AM–9 PM) and reels at 12:30 PM & 8:30 PM.
Sources
- GitHub Blog — "Migrating the GitHub Copilot runtime to Rust, using Copilot" by Stephen Toub (16 September 2026, updated 23 September 2026) — primary source for all figures in this post
- Milan Jovanovic — "GitHub Copilot Runtime Rust Migration: Hype vs. Reality" — benchmark table, memory figures and the "one engineer" caveat
- The Augmented Dev — "GitHub Rewrote the Copilot Runtime in Rust With Agents. The Playbook Is the Story." — method and review layers
- TechByCountry — VS Code 1.143 Copilot Default Explained: Model Bake-Off, On-Device AI and 4x Faster Chats
- TechByCountry — Linux 7.4 Rust Kernel 17000 Lines Explained: Zerocopy Jump, Nova Driver Gains and What It Means
- TechByCountry — Cloudflare tsrs Rust TypeScript Compiler Explained: 8x Faster Type Checks, 70% Less Memory
Comments
Post a Comment