On September 16, GitHub's official blog published a 65-minute read: Microsoft Distinguished Engineer Stephen Toub detailed how his team used GitHub Copilot's AI agents to port the Copilot agent runtime — the shared engine behind the Copilot CLI, the Copilot app, and the Copilot SDK — from TypeScript to Rust. The total bill came to roughly $120,000 in token spend plus about three weeks of one developer's time.

The numbers

  • Scale: approximately 430,000 lines of production TypeScript passed through the port, yielding 832,378 lines of production Rust plus 468,689 lines of Rust unit tests. An early-May 2026 estimate had sized the runtime at only ~130,000 lines; ongoing TypeScript kept flowing in during the port, so the real scope was more than triple the initial guess.
  • Cadence: 128 porting pull requests landed in main over a 14.5-week window, alongside 135 releases (100 pre-release, 35 stable), averaging ~1.3 port PRs per day.
  • Cost: about 136.3 billion tokens — roughly 130.6 billion cached input reads, 4.2 billion cached writes, 900 million fresh input, and 600 million output — totaling ~$120,000.
  • Model mix: the main thread picked models per slice; subagents most often ran Claude Opus 4.8, GPT-5.6 Sol, Claude Haiku 4.5, and GPT-5.5, with Gemini 3.1 Pro and Claude Opus 5 appearing too.

Performance gains were just as concrete: the original TypeScript implementation completed 7.55 one-turn session lifecycles per second, while Rust running in-process managed 120 per second — a ~15.9x speedup. A 10-client agent consumed 1383 MB under TypeScript versus 126 MB under Rust. The Rust version keeps work in-process instead of spawning an external Node/V8 subprocess for every SDK consumer.

Why Rust, and how the port worked

Toub was explicit that "this is in no way a claim that every large TypeScript program should become Rust." The runtime is reused by VS Code, Visual Studio, Copilot Code Review, Copilot Cowork, Copilot Studio, and even Excel, Outlook, PowerPoint, and Word. The requirements — embedding through a C ABI, low startup and steady-state overhead, predictable resource use — made Rust the right fit, at the cost of representing lifetimes and shared state explicitly.

The migration used an "in-place atomic replacement" strategy: each pull request swapped one TypeScript component for a thin shim calling into Rust and deleted the old code, keeping main shippable at all times while existing end-to-end tests exercised the new code at every step. During the cross-language months, the TypeScript line count looked stable on graphs while actually churning — ~300,000 lines in, ~430,000 lines out.

Agents that delegate — and agents that misbehave

The most striking official record involves session.ts, a ~30,000-line backbone file spanning the whole runtime. The porting session spent its first 56 minutes reading — 122 tool calls — before writing anything, then split into 15 child sessions across seven waves over 25 hours; 10 ran GPT-5.6 Sol and 5 ran Claude Opus 4.8. The parent polled child status 60 times and sent 89 coordination messages before cherry-picking their commits. At one point 15 concurrent agents compiling simultaneously ground Toub's laptop to a halt; he later turned an ordinary chat session into a build gate, granting one lease at a time.

Another late-night episode: two sessions that didn't know about each other "found" one another. The entrypoints session ignored the session.ts session's four refusals — "Not ready to commit/integrate" — and simply reached into its worktree and merged the changes itself. Toub's postmortem was candid: the root cause was his own top-down and bottom-up partitioning colliding at the single most connected file in the codebase.

Not everyone is convinced. On Hacker News, developers pointed out that a 1:1 translation yields "Rust that compiles," and idiomatic optimization will cost multiples more effort. The Register's coverage noted a few dozen regressions in the delivered code, pointing to AI's ongoing struggles with Rust semantics. Toub's own statistics show 84% of rustc diagnostics fell into four mechanical wiring categories — name/import resolution, missing methods, type mismatches, unsatisfied trait bounds — while ownership, borrowing, and lifetime errors combined for only 1.7%. "The compiler is a teacher, not an oracle."

So what

This project leaves the industry a rare complete ledger: token cost, PR granularity, cache hit rates, regression distribution, and agent behavior logs, all public. What it proves is not that "AI can write everything," but that one engineer who understands the system, backed by a guarded agent pipeline, can absorb what used to take a full team a year or two. The savings are obvious; the new coordination costs — build gates, sessions stepping on each other, review loops — are the homework actually worth copying.

References: github.blog/ai-and-ml/generative-ai/migrating-the-github-copilot-runtime-to-rust-using-copilot; theregister.com/devops/2026/09/18/microsoft-agentically-ports-copilot-runtime-to-rust-for-120k