# GitHub Rewrote Copilot in Rust: 800k Lines, One Developer

> GitHub rewrote its Copilot agent runtime into 832,378 lines of Rust, mostly by agents, for about $120,000 in tokens. The numbers and the lessons.

- Author: Nitish Garg, Founder & CEO, CellCog
- Published: 2026-09-17
- Canonical (HTML): https://cellcog.ai/blog/github-copilot-runtime-rust-rewrite/
- Section: Insights / Multi-agent & AI organizations
- Publisher: CellCog (https://cellcog.ai), the AI employee platform. Blog index for agents: https://cellcog.ai/blog/llms.txt

## Key points

- GitHub rewrote the runtime behind Copilot CLI, the Copilot app and the Copilot SDK from TypeScript on Node.js into Rust. By August 21, 2026 it was 100 percent production Rust: 832,378 lines, plus 468,689 lines of Rust unit tests and 174,675 lines of end-to-end TypeScript tests kept as the oracle. GitHub published the account on September 17.
- Agents wrote most of the code. The port landed as 128 pull requests on the main branch over roughly 14.5 weeks, in place, one component at a time, while the branch shipped 135 releases. GitHub says the same project would have taken a team a year or two before agents; it was done primarily by one developer, Stephen Toub.
- The bill: about 136.3 billion tokens, of which 130.6 billion were cached input reads, at a 96.22 percent prompt-cache hit rate, for about $120,000. The author estimates roughly three weeks of his own time went to the port, with other engineers contributing design and review.
- The session logs show what the agents did with the time: 630,423 shell calls, 590,988 file views and 281,783 ripgrep searches against 53,715 patches and 40,591 edits. GitHub's reading is that the agents did ten times as much exploration as mutation; the image of AI spewing code is almost backwards.
- What it bought: creating a client, running one turn and tearing down went from 5.25 seconds on the TypeScript runtime to 292 milliseconds with Rust loaded in-process; 1,000 lifecycles from 132.5 seconds to 20.9; memory for ten clients from 1,383 MB above baseline to 126 MB. The runtime now exposes a C ABI of 19 functions that the C#, Python, Go, Java and Rust SDKs call directly.
- It was not clean: dozens of regressions were traced and fixed by September 14, most from missing end-to-end tests. The lessons GitHub lists are the ones anyone running agents needs: state the whole goal, protect the test oracle from the agent that is changing the code, translate before redesigning, and when a failure shows up twice, write it into standing instructions or a skill.

## At a glance

- **What did GitHub announce?** That its Copilot agent runtime, the engine behind Copilot CLI, the Copilot app and the six-language Copilot SDK, has been rewritten from TypeScript into 832,378 lines of production Rust, with AI agents writing most of it across 128 pull requests. The write-up by Stephen Toub was published September 17, 2026 (00:26 UTC; the evening of September 16 in California).
- **What did it cost and how long did it take?** About $120,000 in tokens (136.3 billion, 96.22 percent from prompt cache), roughly three weeks of the lead developer's attributed time, and a porting window of about 14.5 weeks from early May to August 21, 2026, during which the runtime kept shipping.
- **Why does it matter beyond Rust?** It is the largest published, receipt-backed account of agents porting a production codebase, and the author's conclusion is the honest one: agents did not port it on their own, they moved the price to where one engineer could run the project. The lessons are about goals, tests and memory, not about Rust.

At 00:26 UTC on September 17, 2026, GitHub published [Migrating the GitHub Copilot runtime to Rust, using Copilot](https://github.blog/ai-and-ml/generative-ai/migrating-the-github-copilot-runtime-to-rust-using-copilot/), a 65-minute account by Stephen Toub of rewriting the engine behind Copilot CLI, the Copilot app and the Copilot SDK from TypeScript into 832,378 lines of Rust, with agents doing most of the typing. Every figure below is GitHub's own, read from that post; the publish time is the one in GitHub's feed.

A disclosure first: we build CellCog, an AI employee platform, and GitHub Copilot sits at number six in [our ranking of agent harnesses](https://cellcog.ai/blog/best-ai-agent-harnesses/). This is a record of what GitHub reported and what it says about running agents on real code, not a review of Copilot.

## What GitHub did

The Copilot agent runtime is the shared loop that many Microsoft and GitHub products wrap: the CLI, the desktop app, the cloud agent, code review, Cowork, Copilot Studio and the Office apps. It was written in TypeScript on Node.js and V8, with the terminal UI and the runtime intertwined and the SDK layered on top of the CLI, so every SDK client in every language spawned a Node process and talked to it over JSON-RPC. GitHub wanted a runtime that embeds in-process through a C ABI, starts fast, uses little memory and can be called from all six SDK languages. It chose Rust, and says plainly that this "is in no way a claim that every large TypeScript program should become Rust."

The port ran in place: component by component on the main branch, each piece flipped atomically from TypeScript to Rust with interop bridging the rest, so nobody stopped work and the branch stayed shippable. The early-May estimate was about 130,000 lines of TypeScript. The real number that passed through was about 430,000, because the runtime kept absorbing code from the UI layer and taking in new features while the port ran.

*Table: The port by the numbers (GitHub's figures, published September 17, 2026)*

| Measure | Figure |
|---|---|
| Production Rust at completion (August 21, 2026) | 832,378 lines |
| Rust unit tests | 468,689 lines |
| End-to-end TypeScript tests kept as the oracle | 174,675 lines (plus about 130,000 in the SDK repository) |
| Production TypeScript that passed through the port | About 430,000 lines (initial estimate 130,000) |
| Pull requests | 128, landed on main |
| Porting window | Roughly 14.5 weeks, early May to August 21 |
| Releases shipped meanwhile | 135 (100 pre-release, 35 stable), about 1.3 a day |
| Tokens | About 136.3 billion, 130.6 billion of them cached input reads |
| Prompt-cache hit rate | 96.22 percent |
| Token bill | About $120,000 |
| Developer time attributed to the port | Roughly three weeks |
| Regressions traced and fixed by September 14 | Dozens |

The author's own framing of the cost is the sentence the rest of the industry will quote: a rewrite of this size in place, by one engineer supported by a team, "is not a proposal that would have been accepted before agents." It would have needed a team and a year or two, and it would have lost against every feature that team could have shipped. "Agents moved the price to where the project became tenable."

## What the agents actually did

The runtime writes a structured event log for every session, and GitHub mined those logs across all the porting pull requests: 12,760,995 events, 1,385,214 assistant messages, 1,857,409 tool starts, 23,096 compilation commands, 19,485 test commands, 7,410 commits and 5,116 completed compactions. The tool-call breakdown is the useful part.

*Table: Tool calls across the porting sessions (GitHub's session logs)*

| Tool | Calls | Median duration | Measured hours |
|---|---|---|---|
| powershell (shell) | 630,423 | 3 s | 2,833.9 |
| view (read a file) | 590,988 | 0 s | 621.7 |
| rg (ripgrep) | 281,783 | 1 s | 408.4 |
| grep | 126,483 | 1 s | 115.3 |
| apply_patch | 53,715 | 0 s | 17.0 |
| edit | 40,591 | 1 s | 24.1 |
| read_powershell (wait on a command) | 36,728 | 90 s | 1,203.9 |
| task (delegate to a subagent) | 13,080 | 274 s | 2,329.0 |

GitHub's takeaway: across the reading and searching tools versus the editing tools, "they did 10x as much exploration as mutation." Reading files, searching the repository and running diagnostics dominated; edits were small. "The popular image of AI spewing code is almost backwards"; at this scale the work looked like investigation, hypothesis, a targeted change, and again.

Delegation had the same shape. For the hardest file, a parent session ran for 25 hours, made 222 shell calls, 205 file views and 197 ripgrep searches of its own, and spawned 15 child sessions in seven waves over about three hours, each on its own branch and worktree: 10 on GPT-5.6 Sol, five on Claude Opus 4.8, all in autopilot mode, the median kickoff prompt about 1,100 characters. Across the whole port the subagents most often ran on Claude Opus 4.8, GPT-5.6 Sol, Claude Haiku 4.5 and GPT-5.5, then Gemini 3.1 Pro and Claude Opus 5; three common subagent definitions pinned their own models, so part of that mix was the subagent's choice rather than the developer's. A separate review pass had agents on Opus 5, GPT-5.6 Sol and Grok 4.6 compare the TypeScript and Rust behaviors.

The cache line matters for anyone paying these bills. Of 136.3 billion tokens, 130.6 billion were cached input reads, a 95.8 percent share and a 96.22 percent hit rate by GitHub's own measure; providers typically bill cache hits at around a 90 percent discount, which is the difference between a $120,000 port and a much larger one.

## What it bought

GitHub measured the delivered systems end to end with a deterministic local model server, so model and network latency are excluded: the May 12 TypeScript runtime over stdio against the August 21 Rust runtime, both as an out-of-process server and loaded in-process through FFI.

*Table: Runtime performance before and after (GitHub's C# SDK benchmark, model latency excluded)*

| Scenario | TypeScript, May 12 | Rust out-of-process, Aug 21 | Rust in-process, Aug 21 |
|---|---|---|---|
| Client, session, one turn | 5.25 s | 1.33 s (4.0x) | 292 ms (18.0x) |
| Resume a 32-turn session | 5.64 s | 1.52 s (3.7x) | 264 ms (21.4x) |
| Ten concurrent client lifecycles | 12.34 s | 4.18 s (3.0x) | 742 ms (16.6x) |
| 1,000 one-turn lifecycles | 132.52 s | 22.53 s (5.9x) | 20.93 s (6.3x) |
| One-turn lifecycles per second | 7.55 | 57.45 | 120.0 |
| Aggregate CPU, 100-by-10 workload | 312 s | About 110 s | About 110 s |
| Memory added, ten clients | 1,383 MB | 247 MB | 126 MB |

GitHub is careful about the headline: the 15.9x throughput gain is a workload-specific result, the runtime is not universally that much faster, and other changes landed in the same window. The architectural payoff is the second door: a C ABI with 19 exported functions, behind which the shared contract carries 364 dispatch methods, so the C#, Python, Go, Java and Rust SDKs load the runtime in-process instead of shipping a second language runtime of about 100 MB per client.

## What went wrong, and the lessons

"Making it correct is hard." By September 14, 2026, 24 days after completion, GitHub had traced dozens of known port regressions, mostly correctness bugs, all fixed; some were caught in the repository, some in pre-release, some reached a stable release. With one exception, every regression that involved a missing feature came from too few end-to-end tests. The plan had called for improving end-to-end coverage before starting, GitHub did, and says it did not do enough.

The lessons GitHub lists read as an operating manual for agents on production code:

- **State the whole goal.** "Port XYZ component to Rust" was read as hot paths only, or logic only, with I/O and orchestration treated as out of scope. Once the end state was stated as a native binary from a 100 percent Rust codebase, with no execution environment left for TypeScript, the agents drove to it.
- **End-to-end tests are the oracle**, and they cannot be rewritten during the port, or the oracle is lost.
- **"Protect the oracle from the agent."** The agent changing an implementation cannot also weaken a test, update a snapshot, raise a compatibility baseline or apply an escape-hatch label without oversight. Keep the behavioral contract independent; put sensitive guardrails behind separate ownership or approval; layer checks with different failure modes.
- **"Translate first, redesign second."** Preserving behavior kept the number of moving variables manageable. The author says he strayed a few times and regrets every one; each cost more regressions, time or tokens than staying the course.
- **Turn repeated failures into future successes.** "When a failure mode shows up twice, it belongs in standing instructions, a reusable skill, an eval, a protected baseline, or the harness itself."
- **The inner loop matters more with agents, not less.** Agents think and write quickly and then build and test, so the share of their time spent in the build-test loop rises; optimize it, and optimize it for many worktrees at once.

And the honest close: GitHub did not ask an agent to port the codebase in one instruction, and says the industry is not there yet. What agents did was make a category of project feasible.

## Read next to the Nous refactor

Two weeks apart, two receipt-backed accounts of agents working on production code at scale. [Nous Research](https://cellcog.ai/blog/nous-hermes-1393-agents-refactor/) ran 1,393 agents for about 19 hours and cut a million-line repository by 34.4 percent for about $19,300, wide and short. GitHub ran one engineer's sessions for 14.5 weeks and produced 832,378 new lines in another language for about $120,000, narrow and long. Both credit one coordinating layer that framed the work and mechanical checks that kept it honest; both list the regressions. GitHub's addition is the price of correctness written down, and a memory rule that is the same in both stories: what the agents learned went into standing instructions and skills, not into a human's head. That rule is the one we would underline, because it is how [an organization of AI employees](https://cellcog.ai/blog/cellular-multi-agents/) keeps working after the person who set it up has moved on.

## What we are watching for

- **The SDK release notes.** GitHub says the CLI still calls into runtime internals in places and that moving it onto the SDK surface is ongoing; the first SDK release that ships the in-process runtime by default lands here.
- **A regression count after a month.** The September 14 figure is 24 days after completion. A later count, or a stable-release incident traced to the port, updates this record.
- **The next big port.** The author calls agents moving the price the real story. The next published account of a comparable rewrite, from GitHub or anyone else, goes into [the harness ranking](https://cellcog.ai/blog/best-ai-agent-harnesses/) as evidence.

## Update log

- **September 17, 2026, 14:10 UTC.** Page opened, about fourteen hours after publication. Every figure read from GitHub's post; multipliers and gaps recomputed from its numbers.

## Sources

Stephen Toub, GitHub, [Migrating the GitHub Copilot runtime to Rust, using Copilot](https://github.blog/ai-and-ml/generative-ai/migrating-the-github-copilot-runtime-to-rust-using-copilot/), published September 17, 2026, 00:26 UTC per GitHub's feed (bylined September 16 in Pacific time). Comparison figures for Nous Research from [our record of the Hermes refactor](https://cellcog.ai/blog/nous-hermes-1393-agents-refactor/), sourced there to Nous Research's September 15 write-up.

## FAQ

**Who did the work?**

GitHub says the port was completed primarily by a single developer, Stephen Toub, with agents writing most of the code, and names other engineers who designed interop pieces and reviewed. The runtime team kept expanding the runtime in parallel; about 300,000 new lines of production TypeScript passed through the port while it ran.

**Which models ran the agents?**

The subagents most often ran on Claude Opus 4.8, GPT-5.6 Sol, Claude Haiku 4.5 and GPT-5.5, followed by Gemini 3.1 Pro and Claude Opus 5, partly determined by which subagent definition was chosen. For the hardest single file, a parent session spawned 15 child sessions in seven waves over about three hours: 10 on GPT-5.6 Sol, 5 on Claude Opus 4.8, all in Copilot's autopilot mode.

**How does it compare with the Nous Research refactor?**

Nous ran 1,393 agents for about 19 hours to make a million-line repository 34.4 percent smaller, for about $19,300. GitHub ran a long in-place port over 14.5 weeks that produced 832,378 new lines in a different language, for about $120,000. Both credit one coordinating layer and mechanical checks; GitHub's account adds the cost of correctness, with dozens of regressions traced and fixed.

**What went wrong?**

By September 14, 2026 GitHub had traced dozens of known port regressions, mostly correctness bugs, all fixed. With one exception, every regression that involved a missing feature came from insufficient end-to-end tests. Early instructions were also too vague: agents read a port request as hot paths only, until the end state was stated as a native binary with no TypeScript execution left.

**What are the lessons GitHub lists?**

State the goal fully. End-to-end tests are critical and must not be rewritten during the port, or the oracle is lost. Protect the oracle from the agent: the agent changing code cannot silently weaken a test or raise a baseline. Translate first, redesign second. When a failure mode shows up twice, put it in standing instructions, a skill, an eval, a protected baseline or the harness. And invest in the build-and-test inner loop, because agents spend more of their time there, not less.

## Related

- [Nous Research Cut 1M Lines of Code With 1,393 Agents](https://cellcog.ai/blog/nous-hermes-1393-agents-refactor/index.md)
- [Best AI Agent Harnesses: September 2026 Rankings Across the Full Agent Stack](https://cellcog.ai/blog/best-ai-agent-harnesses/index.md)
- [Human Span of Control for AI Agents: A Workload Model for Safe Supervision](https://cellcog.ai/blog/human-span-of-control-ai-agents/index.md)
- [Cellular Multi-Agents: The Harness We Built for the Endgame, Not for Today's Models](https://cellcog.ai/blog/cellular-multi-agents/index.md)

## The AI employee for this read

[AI Software Engineer](https://cellcog.ai/ai-employees/ai-software-engineer): I built this page. For what it covers, hire an engineer: it works in your repo behind an approval gate, so nothing reaches your world unclassified.

---

Markdown alternate of https://cellcog.ai/blog/github-copilot-runtime-rust-rewrite/. Try CellCog free, no credit card needed: https://cellcog.ai/signup
