GitHub Rewrote Copilot's Runtime in Rust for $120,000
Software / analysis
GitHub Rewrote Copilot's Runtime in Rust for $120,000
A single Microsoft engineer directed AI coding agents through 128 pull requests over 14 weeks, cutting the memory a 10-client batch needs from 1,383 megabytes to 126.

GitHub spent about $120,000 in AI token costs and three weeks of one engineer's time to rewrite the runtime behind Copilot CLI, the Copilot app and the Copilot SDK from TypeScript into Rust, Microsoft Distinguished Engineer Stephen Toub wrote in a Sept. 16 GitHub blog post.
Toub said he did the port largely alone, directing AI coding agents rather than writing most of the code himself, between May 12 and Aug. 21. The work spanned 128 pull requests merged into the main branch and 135 separate CLI releases along the way, an average of more than one a day.
What agents actually wrote
The runtime originally ran on TypeScript and Node.js, using Google's V8 JavaScript engine to execute it. Toub said that architecture required every client to launch a separate Node.js process, load a JavaScript runtime and communicate with it over JSON-RPC, adding roughly 100 megabytes of working-set memory per client before any actual work began.
The finished Rust codebase runs to 832,378 lines of production code plus 468,689 lines of Rust unit tests, ported from an original TypeScript base Toub said grew to about 430,000 lines because feature work continued during the port. He described the original estimate of roughly 130,000 lines as "wildly misleading" once scope crept in.
AI agents, cycling through Claude Opus 4.8, GPT-5.6 Sol and Claude Haiku 4.5 across sessions, wrote most of that code. Toub said his own role was "framing problems, defining boundaries, choosing strategies, adjudicating exceptions" rather than writing syntax, and that the sessions ran a 96.22 percent prompt cache hit rate across 5,116 context compactions. The port also removed about 60 npm dependencies and consolidated eight OpenTelemetry packages into four Rust crates.
What changed for anyone running the CLI
GitHub's own numbers, charted from the blog post, show why the company calls the result a step change rather than an incremental gain. In a pressure test running 1,000 one-turn session lifecycles, the pre-port TypeScript CLI completed 7.55 of them a second. The Rust version, run out of process, reached 57.45; run in the same process as the caller, it reached 120.
- TypeScript CLI7.55 sessions/sec
- Rust, out of process57.45 sessions/sec
- Rust, in process120 sessions/sec
Source: GitHub Blog, Sept. 16, 2026
| Metric | TypeScript runtime | Rust runtime |
|---|---|---|
| 10-client session memory | 1,383 MB | 126 MB |
| Client creation to first turn | 5.25 sec | 55.3 ms |
Those figures matter most to anyone embedding the GitHub Copilot SDK in another tool, since each additional client used to mean another Node.js process. Microsoft has made Rust a tier-1 language alongside C++ and C#, and this port is the largest internal project built on that decision so far.
The savings also came from what the port removed. Toub said the team eliminated roughly 60 npm dependencies outright and replaced five packages with custom Rust implementations rather than porting them line for line. Eight separate OpenTelemetry packages, used for tracing and monitoring, collapsed into four Rust crates doing the same job.
The regressions nobody has found yet
Toub's post is unusually direct about what went wrong. He said the port produced "dozens of known port regressions, all fixed" by Sept. 14, sorted into categories: ambiguous semantics around type conversions, ambient behaviors such as timezone and environment-variable handling, incomplete migrations, lifecycle and ownership bugs, and features the port simply missed.
"I'm 100% sure there are more than the ones we know about," Toub wrote, citing quiet corner cases that only show up in production use. The finished code contains 158 blocks of unsafe Rust, all of them at foreign-function-interface boundaries with C ABIs, Windows and POSIX system calls, and SQLite.
A Rust conference's verdict on AI-written Rust
Toub's own explanation is that a compiler is a poor judge of correctness. "That's in no way an argument against Rust's compiler," he wrote. "But 'if it compiles, it's correct' is useful only as a joke."
That view found an echo at RustConf in Montreal the week before Toub's post went up. Consultant Lisa Crossman warned attendees against treating the Rust compiler as an oracle on whether AI-generated code is valid, The Register reported. "Rust stops the agent writing memory unsafe code," Crossman said. "It does not stop the agent writing the wrong program correctly." GitHub's own regression list, spanning branch drift and overlooked features, is close to a worked example of her point.
Toub did not say whether GitHub plans to repeat the approach on other services, and the post does not break down the $120,000 by model or by phase of the project. His own framing is narrower than the headline number suggests: "This is in no way a claim that every large TypeScript program should become Rust."

GitHub has been public about trimming Copilot's costs elsewhere in 2026, including cutting the token cost of its own prompts. The Rust runtime is a different kind of cut: not a smaller bill for calling a model, but a smaller bill for running the software that calls it, and one that took three weeks of a Distinguished Engineer's attention to collect.
Sources
More in Software
- 01Vercel's json-render Quietly Wires In TypeSafe's Jev ModelVersion 0.21.0 of the generative-UI framework adds a TanStack Start renderer and an experimental composition mode built on Jev, the decision model TypeSafe AI has not shipped weights for.
- 02TIN Beats ParadeDB by 57x in PlanetScale's Own Postgres TestThe extension is listed as a supported community extension on PlanetScale's own Postgres product, but there is no independent repository, published license, or way to install it outside that service.
- 03SearXNG's Creator Ships Hister 0.19, a Search Engine for OneAdam Tauber's self-hosted index now extracts full ChatGPT and Hacker News threads and speaks the Model Context Protocol, so an AI agent can search a user's own browsing history instead of the open web.
- 04Cua Ships CUA-S1-Forms With a Checkpoint It Can't LoadThe 706,048-parameter model scored 99.7 percent against a rival's hosted service in Cua's own test, but the file it shipped needed a same-day fix before its own code would open it.