Skip to content
AI.info

The Pulse

Microsoft Moved Copilot Cowork’s Live Runtime From Python to Rust

Microsoft describes moving Copilot Cowork’s live runtime from Python to Rust, with production traffic shifted by cluster and the final cluster moved on October 10. Its account details the performance comparison, the behavioral tests used du

Microsoft Moved Copilot Cowork’s Live Runtime From Python to Rust

AI.info Team · Written with AI · fact-checked ·

Python helped Microsoft get Copilot Cowork to general availability in June; at the scale the service reached afterward, the company says, its Python runtime caused event-loop stalls, hidden timeouts and memory trouble. Microsoft published details of the switch to Rust on November 2, describing a migration that moved production traffic in stages and finished on October 10.

The account, written by Bas Brekelmans, a partner software engineer at Microsoft, puts the trade-off plainly:

Python got us to GA quickly, and I don’t think we would’ve made the June date with anything else.

Bas Brekelmans, partner software engineer, Microsoft

The rewrite was not a claim that Rust alone explains the performance gains. Brekelmans wrote that moving the agent loop out of a slow-starting container and into the Rust service accounted for a large part of the improvement, in his view.

Python’s event loop became a production bottleneck

Microsoft says each Python process had one event loop, and under load it measured stalls of up to 11.9 seconds. During a stall, work in that process waited, including lock renewals; some turns lost their locks before they finished. The team also found that 16.7% of session setups took exactly five seconds, which it traced to a timeout firing rather than useful work.

Memory pressure added another warning sign: when the system ran out of memory, the process that got killed was almost always the Python one: 539 times in one week on a single cluster. Moving blocking work off the event loop helped, Brekelmans wrote, but exposed what the team saw as the underlying limit: the single loop, not one particular blocking operation.

Fixtures gave the Rust port a behavioral test

Instead of trying to review Rust against Python line by line, the team generated test fixtures by running the existing Python code over selected inputs. Those JSON records capture outputs such as response bodies, status codes, log lines and storage writes; Rust tests replay them and must match. Microsoft says it had about 430 fixtures, and the generators could check that each fixture still matched the Python behavior.

The fixtures also preserved the old runtime’s behavior after its code was removed. One gap surfaced during the migration: Python had delivered some events in order without that rule being documented, while the first Rust version did not. No fixture caught the difference because the team had not recorded event ordering. Microsoft says it fixed the problem, along with a separate issue that made the first Rust front door take about six times longer to acknowledge a new message.

Traffic moved by cluster, with a rollback path

The first internal attempt on September 23 was rolled back. Rust handled its first production turns the next day, and Microsoft says it shifted traffic one cluster at a time behind flags that could switch back. The team deleted the Python runtime on October 9—about 8,000 files and 4.9 million lines, including tests and generated code—and moved the last cluster on October 10.

In a comparison of Python and Rust clusters over the same 12-hour period in late September, time to first token on the first turn of a session fell from 7.9 to 2.7 seconds at the median. At the 90th percentile, it fell from 14.5 to 6.2 seconds. Microsoft says the event-loop stalls and five-second setups are gone, but it has not properly measured cost per turn and is making no cost claim.

The speedup came with a larger engineering process

The migration was part of a broader build effort in which Microsoft says agents wrote most of Copilot Cowork’s code while engineers set specifications, boundaries and review rules. On October 21, nine engineers merged 1,211 pull requests into the backend’s main branch. The team says agents could propose changes, but could not decide what was allowed to reach production; people retained decisions over deployment and configuration.

Microsoft’s account presents the migration as a test of that approach, not as proof that automated coding removes the need for engineering judgment. The company says the cutover had a written runbook and design records before traffic moved, and that it recorded behavior and moved traffic in steps it could reverse. The post also describes event-ordering behavior that its fixtures had not caught. The final Python cluster moved on October 10.

Source

Explore

More articles