GitHub OldStephen Toub65 min readadvanced
Migrating the GitHub Copilot runtime to Rust, using Copilot
Summary
The Copilot agent runtime was rewritten from a 130‑k‑line TypeScript/Node.js codebase into a native Rust library (~830 k lines of Rust) to reduce startup latency, memory use, and improve reliability. The migration was done incrementally (in‑place) across 128 PRs, with AI‑generated code handling most of the work. The new runtime exposes a C ABI for in‑process embedding by all six Copilot SDK langu…
- Porting a large, actively‑developed runtime in‑place (component‑by‑component) avoids a costly big‑bang cutover and lets you keep up with upstream changes.
- Rust provides low‑overhead, predictable memory and startup characteristics, making it suitable for a shared agent runtime that must be embedded in many host languages.
- Exposing a thin C ABI enables clean in‑process embedding across C‑FFI‑compatible languages (C#, TypeScript, Python, Rust, Go, Java) without pulling in a full Node/V8 runtime.
- Separating the TUI from the core runtime clarifies layering, allowing the UI to sit on top of a stable SDK surface instead of being intertwined with core logic.
Embedding a heavyweight Node/V8 runtime in every SDK client inflated memory (≈100 MiB per process), slowed startup, and added a failure surface. By moving to a native Rust library, GitHub can ship a lightweight, high‑performance agent that scales better in server‑side and desktop environments, redu…
7/10



