Migrating the GitHub Copilot Runtime to Rust, with Help from Copilot
By Stephen Toub, Distinguished Engineer at Microsoft
As AI-assisted development reaches new levels of sophistication in 2026, the story of how GitHub Copilot's own runtime was migrated to Rust—using Copilot itself—offers a compelling look at the future of software engineering: AI tools accelerating the very systems that power them.
Why Rust?
The original GitHub Copilot runtime was built on a mix of technologies, but as demand for Copilot grew, the limitations of the existing stack became apparent. Latency, memory safety, and concurrency bottlenecks pushed the team to consider a rewrite. Rust emerged as the ideal candidate:
- Memory safety without garbage collection
- Zero-cost abstractions
- Excellent concurrency support
- Strong ecosystem for performance-critical services
Using Copilot to Migrate Copilot
In a delightfully recursive twist, the team used GitHub Copilot to assist in the migration. Copilot helped:
- Translate idiomatic patterns from other languages into Rust
- Generate boilerplate for FFI bindings and async runtimes
- Suggest unsafe code alternatives with safer constructs
- Write unit tests to validate behavior parity
This wasn't blind automation—engineers reviewed and refined every suggestion—but it dramatically reduced the time spent on mechanical translation.
Challenges and Lessons Learned
- Borrow checker friction: While Rust's borrow checker prevents entire classes of bugs, it required rethinking ownership models in the original code.
- Async runtime choices: The team evaluated
tokiovsasync-stdand ultimately standardized ontokiofor its maturity and ecosystem. - Interop with existing services: Gradual migration via FFI allowed incremental adoption without a full rewrite.
- AI hallucinations: Copilot occasionally suggested non-existent crates or outdated APIs, necessitating careful review.
- ~40% reduction in memory usage
- 2x improvement in p99 latency
- Fewer runtime panics due to Rust's safety guarantees
- Faster onboarding for new engineers thanks to clearer code and tooling
Results
The Bigger Picture
By 2026, AI-assisted migrations like this are becoming the norm rather than the exception. Tools like GitHub Copilot are not just writing code—they're reshaping how we approach large-scale system rewrites. The Copilot-on-Copilot migration is a proof point that the future of software is collaborative, recursive, and increasingly efficient.
Stephen Toub is a Distinguished Engineer at Microsoft, focusing on runtime performance and developer tooling.
via GitHub AI Blog
