GitHub has completed a major rewrite of its Copilot agent runtime—originally built in TypeScript and Node.js—by migrating it entirely to Rust. The project, which spans over 800,000 lines of production code, was executed primarily using the Copilot AI agent itself, marking a significant milestone in AI-driven software engineering.
The Copilot agent runtime is the foundational layer behind several GitHub and Microsoft products, including the GitHub Copilot CLI, VS Code, Visual Studio, Excel, Outlook, PowerPoint, and Copilot Code Review. These tools rely on a shared agent loop to deliver AI-powered code suggestions and automation. As the ecosystem expanded, the original architecture—built for rapid development—became a bottleneck in terms of performance, memory usage, and reliability.
What Happened: A Rewrite by AI
Instead of relying on a traditional team of developers to manually port the runtime, GitHub used the Copilot AI agent to generate most of the Rust code. The migration was not a single, monolithic effort but a phased, incremental process spanning several months and involving 128 pull requests that were merged into the main codebase over time.
By August 2026, the runtime was fully rewritten in Rust, with 832,378 lines of production code and 468,689 lines of unit tests. Additional end-to-end testing was conducted in TypeScript across the SDKs, with over 130,000 lines of E2E test code added for Node.js, Python, Go, C#, Rust, and Java.
Key Facts and Metrics
- The migration involved over 800,000 lines of production Rust code.
- AI-generated code accounted for the majority of the implementation, with only a small fraction of manual oversight.
- Performance improved significantly—by orders of magnitude—across startup time, memory usage, and throughput.
- The rewrite was completed by a single developer in a few months, a feat that would have taken a full team of engineers a year or more before AI agents.
- The migration was done incrementally, with small, isolated components ported first (e.g., pure-logic primitives), followed by larger subsystems like session orchestration and model clients.
- Each phase was validated through testing, with a clear progression from leaf components to core systems.
Background: How the Copilot Runtime Works
Originally, the Copilot agent runtime operated as a terminal UI (TUI) built on TypeScript and Node.js, using the V8 JavaScript engine for execution. This architecture allowed rapid development and deployment but introduced several performance and scalability issues.
Key architectural challenges included:
- Node.js and V8 execution overhead—each SDK consumer had to spawn a separate Node.js process, consuming up to 100 MB of memory and introducing a full second language runtime.
- Out-of-process communication via JSON-RPC, which created latency and made debugging difficult.
- Crash propagation—any crash in the Node process would terminate the entire session.
- Limited interop across languages—each SDK required a separate runtime, increasing deployment complexity.
GitHub’s goal was to create a runtime that could be embedded in-process, with minimal dependencies, high performance, and strong security. Rust was chosen for its memory safety, performance, and ability to support clean interop across languages via foreign function interfaces (FFI).
Why It Matters: Shared Intelligence, Better Performance
By moving the runtime to Rust, GitHub achieved a unified, high-performance foundation for its AI-powered tools. This shared runtime enables consistent AI behavior across diverse products—from code editors to office applications—without each product having to reinvent the agent loop.
For developers, this means:
- Reduced memory footprint and faster startup times in production environments.
- Improved reliability—crashes in one component no longer affect the entire session.
- Lower supply chain risk due to Rust’s proven toolchain and security model.
- Greater scalability and performance, especially in server-dense, low-memory environments.
Moreover, the migration demonstrates a new paradigm in software development: using AI agents to generate and maintain large-scale, production-grade codebases. This approach reduces human effort and accelerates delivery, especially in fast-moving fields like AI and development tools.

Limitations and Open Questions
While the migration is a major technical achievement, it is not without caveats:
- The success of this approach depends on the quality and safety of AI-generated code. Though the runtime is now stable, the process requires rigorous testing and human oversight to catch edge cases.
- Not all TypeScript code can be ported to Rust—some abstractions and patterns are inherently language-specific.
- Long-term maintenance of AI-generated code remains a challenge, especially as the codebase grows and evolves.
- The migration was successful in a controlled environment; real-world performance under heavy load or in distributed systems may require further validation.
Additionally, this case does not imply that every TypeScript project should be rewritten in Rust. The decision was driven by specific performance, security, and architectural needs, not a general recommendation.
What to Watch Next
As GitHub continues to expand its AI-powered tools, several developments will be closely watched:
- The integration of the new Rust runtime into Copilot Studio and other enterprise tools.
- How the migration impacts developer experience in low-resource environments, such as mobile or embedded systems.
- Whether other companies adopt similar AI-assisted migration strategies for legacy codebases.
- How Rust’s role in AI and agent development evolves as more tools adopt it.
For developers and organizations building AI-powered applications, this case offers a compelling model: using AI not just to assist, but to drive the core engineering of large-scale systems.
Original source: GitHub Blog
Learn more about how GitHub Copilot handles complex pull requests: How GitHub Copilot Handles Million-Line Pull Requests.
Explore how AI is reshaping development workflows with Why Chat Is the Wrong UI for AI Development Tools.
See how GitHub uses AI to test C/C++ code with GitHub’s AI-Powered Fuzzing Tool for C/C++ Projects.
For a deeper dive into Copilot’s workflow capabilities, see Building Custom Workflows with GitHub Copilot Canvases.
Sources & further reading
Featured image: SH100-B897V1-4;
Siemens SH 100 family (Telecom).
ECL Gate Array;
Case: PGA64CG by Mister rf, CC BY-SA 4.0, via Wikimedia Commons. Image source · License
