GitHub Copilot Runtime Migrated to Rust
GitHub has successfully rewritten the entire Copilot runtime environment, transitioning from TypeScript to Rust. Astonishingly, Copilot’s own artificial intelligence agents generated the vast majority of this new codebase. This monumental migration consumed approximately three and a half months, transforming an initial estimate of 130,000 lines of TypeScript into a robust 832,378 lines of functional Rust code.
This critical runtime environment serves as the foundational architecture for the GitHub Copilot CLI, the standalone Copilot application, and the Copilot development kit. Furthermore, it powers vital integrations within VS Code, Visual Studio, Copilot Studio, and several prominent Microsoft 365 products. GitHub executives decided to abandon the legacy architecture—comprising TypeScript, Node.js, and the V8 engine—due to excessive memory consumption, frustrating startup delays, and the inherent complexity of embedding Copilot directly into external programs.
The Immense Scale of the AI-Assisted Migration
Engineers initiated this ambitious endeavor in May 2026. However, the preliminary estimate of 130,000 lines quickly proved hopelessly inaccurate. Developers continuously modified the project concurrently with the ongoing migration, frequently transplanting legacy code from other components directly into the runtime environment. Consequently, approximately 430,000 lines of operational TypeScript underwent translation during the project, ultimately resulting in a Rust codebase nearly twice that size.
Rather than developing an entirely separate version and subsequently forcing users through a massive, singular update, the development team adopted a phased approach. They meticulously transitioned individual components to Rust sequentially, committing these changes directly to the primary development branch. Over a grueling 14.5-week period, GitHub successfully merged 128 pull requests strictly related to the migration and deployed 135 distinct versions, including 35 stable releases. By August 21, the operational core of the runtime environment consisted of 100% Rust code.
Why Rust? Performance, Predictability, and Safety
The strategic selection of Rust extended far beyond mere execution speed. GitHub desperately required natively compiled executable code boasting minimal overhead, highly predictable resource consumption, and the unparalleled capability to operate seamlessly within the memory process of another application. Furthermore, Rust’s inherent memory safety provided a compelling secondary argument. The Rust compiler proactively prevents numerous memory manipulation errors during the compilation phase, although it cannot entirely insulate a program from logical flaws or other complex vulnerability classes.
During isolated performance benchmarks, the disparity between the legacy architecture and the new implementation appeared profoundly striking. Previously, the sequence of instantiating a client, launching a session, executing a single model query, and terminating the process consumed a sluggish 5.25 seconds. Conversely, launching the new environment directly within a host process required a mere 55 milliseconds. In a separate stress test, throughput skyrocketed from 7.55 to an astonishing 120 short sessions per second. However, GitHub explicitly cautions that these impressive figures apply only to specific, controlled scenarios and do not guarantee a universal 16-fold acceleration across all Copilot operations.
Memory consumption also plummeted dramatically. In a rigorous test involving ten concurrent clients, the legacy implementation bloated memory usage by approximately 1383 MB. The new Rust implementation, operating as a distinct process, required only 247 MB. Remarkably, the embedded variant consumed a mere 126 MB, representing an astounding 91% reduction compared to the original architecture.
The Crucial Role of Autonomous AI Agents
The sheer magnitude of this endeavor is most apparent when examining the frenetic activity of the AI agents. Official project logs document over 1.85 million tool executions, with subordinate AI agents initiating a staggering 61% of the approximately 1.13 million recorded calls. You can explore a detailed technical breakdown of migrating the GitHub Copilot runtime to Rust using Copilot on the official engineering blog.
Lead developer Stephen Toub estimated his direct personal involvement at approximately three weeks of dedicated labor. Instead of manually writing the immense volume of code, his responsibilities shifted toward meticulously defining task boundaries, rigorously validating AI-generated solutions, supervising comprehensive test suites, and inevitably returning incomplete or flawed segments back to the agents for revision.
Despite this heavy reliance on automation, the project did not escape human error entirely. By September 14, the team had identified several dozen regressions. These issues encompassed subtle behavioral discrepancies between the legacy and modern implementations, complex state and object lifetime management problems, incomplete function translations, and critical boundary errors occurring between distinct components. The team swiftly rectified all known regressions, successfully intercepting several critical issues before they infiltrated the stable release branches.
Ultimately, powering the AI operations consumed approximately 136.3 billion tokens, with the overwhelming majority stemming from efficiently recycled cache data. The financial expenditure for these tokens reached approximately $120,000. However, GitHub emphasizes that this figure severely underestimates the total project cost, as it excludes the invaluable human labor and the crucial contributions of numerous engineers involved in architecture design, packaging, validation, and final code integration.
Toub confidently asserted that without the assistance of AI agents, rewriting such a colossal, active system would have necessitated a dedicated engineering team and consumed one to two years of continuous effort. Nevertheless, this migration experience clearly delineated the current boundaries of automation. While the agents excelled at managing massive volumes of translation, they demanded relentless human supervision, rigorous end-to-end testing, and independent verification to guarantee that the new implementation faithfully preserved the original system behavior.
Support Our Threat Intelligence
If you find our technology report and cybersecurity news helpful, consider supporting our work.