SUGATA AI
GitHub Blog

Migrating the GitHub Copilot runtime to Rust, using Copilot

Migrating the GitHub Copilot runtime to Rust, using Copilot

There was a time when the prospect of porting a complex, mission-critical software system to a new language felt like an insurmountable mountain, a task reserved for teams with unlimited budgets and months of runway. That era ended not with a bang, but with the arrival of AI agents capable of reasoning through codebases and executing migrations autonomously. At GitHub, we faced the monumental challenge of rewriting our Copilot runtime, a system spanning roughly 800,000 lines of production code, from Go to Rust. Before agents, this rewrite was simply not affordable; the opportunity cost of manual labor was too high. Today, we are witnessing the moment where the toolset used to build the future of software development actually facilitates its own evolution.

The decision to move to Rust wasn't just about performance or memory safety, although those were significant factors. It was about control and longevity. We needed a runtime that could operate with near-zero latency, managing the intricate orchestration of language models without becoming a bottleneck itself. Porting a system of this magnitude is usually a recipe for disaster, where human error creeps in during the translation of business logic. However, by leveraging Copilot agents to handle the heavy lifting of the port, we transformed what would have been a year-long slog into a manageable engineering endeavor. The agents didn't just write syntax; they understood the context, the edge cases, and the architectural patterns that held the original Go implementation together.

What makes this migration particularly fascinating is the recursive nature of the work. We were using the very system we were rewriting to rewrite itself. It creates a unique feedback loop where the agent analyzes the legacy Go code, proposes Rust equivalents, and then we, the human engineers, step in not to write the code from scratch, but to act as the final gatekeepers, verifying the logic and ensuring the semantic integrity remained intact. This shift changes the role of the developer from a typist to an architect and a conductor, orchestrating a symphony of automated reasoning that accelerates the pace of innovation.

The technical hurdles were real, even with the assistance of agents. Rust's strict ownership model and lack of garbage collection require a mindset shift that no amount of code completion can fully automate. The agents struggled initially with complex concurrency patterns and specific library abstractions that didn't have direct Rust counterparts. Through iterative prompting and human-in-the-loop refinement, we taught the system to recognize these patterns and generate idiomatic Rust solutions. The result is a runtime that is not only faster and safer but also more modular, allowing us to make changes that were previously too risky to attempt.

This migration stands as a testament to the evolving relationship between developers and their tools. It challenges the old adage that you must build something from the ground up before you can trust it. Instead, we found that we could trust our tools enough to let them help us build something better, faster, and with fewer errors. The journey from 800,000 lines of Go to Rust proves that when you align your infrastructure with your goals, even the most daunting technical debts can be paid off, leaving you with a system that is ready for the next decade of AI-driven development.

πŸ¦‹ Free for 60 days

On Bluesky? Meet HomeSky.

Follower analytics, a growth toolkit, scheduling and AI posting β€” built for Bluesky. Connect your account and use everything free for 60 days.

Try HomeSky free β†’