GitHub rewrote the Copilot engine in Rust — using Copilot itself
Translated by a model; the original is in Russian.
GitHub has described how, over the course of a few months, it completely rewrote the runtime of its Copilot from TypeScript (Node.js and the V8 engine) to Rust. This is the agentic engine that powers the Copilot CLI, the Copilot app, the cloud agent, and SDKs for six languages at once — C#, TypeScript, Python, Go, Java and Rust. The result: more than 832,000 lines of production Rust plus nearly half a million lines of unit tests.
The most remarkable part: most of the code was written not by people but by AI agents. The work proceeded through 128 pull requests that were merged into the main branch gradually, rather than with a single “big switch” at the end. By the estimate of the author, Stephen Toub, a project that previously would have required a whole team and a year or two was essentially carried here by a single developer over a few months, while the others kept building out the runtime's functionality.
Why they moved away from Node
The old architecture forced every SDK consumer to drag along a full Node.js and V8 — at least 100 MB of memory per client, a separate process for supervision, and data exchange across the process boundary for every message. Rust was chosen for its minimal dependencies, fast startup, server-side density, and clean in-process embedding via the C ABI. The port was done “in place,” component by component: each pull request replaced TypeScript with a thin shim over Rust and immediately deleted the old code, while the end-to-end tests served as the reference for correctness.
The numbers and the payoff
Creating a client, a session and running a single turn sped up from 5.25 seconds to 292 milliseconds when embedded in-process — an eighteenfold gain. Memory consumption for a batch of ten clients dropped from 1383 MB to 126 MB. At the same time, the port was deliberately a “translation without redesign”: the algorithms were left as they were, deferring a redesign around Rust's ownership model to the future.
The total token bill came to about $120,000 (136 billion tokens, of which 96% were cheap cache reads) plus roughly three weeks of developer time. Of the dozens of regressions uncovered, the author says, not a single one involved unsafe blocks — there are only 158 of them, and they all pertain to interop.
When the agents strike deals on their own
The author also debunks the beloved meme “if it compiles, it works”: every bug on the regression list compiled successfully. The most bizarre episode was two parallel sessions “finding each other.” The session porting the entry points, against its instructions, invoked the orchestration skill on its own, asked the neighboring session four times whether it was ready to merge its changes, was refused four times — and in the end simply reached into the other session's working directory and took everything itself. The author's takeaway is sober: parallel agents working over adjacent code need a designated coordinator or a human, and “work autonomously” should carry an exception for decisions that reach beyond one's own branch.
Source: GitHub Blog
Comments
Sign in, to comment.