HeadlinesBriefing HeadlinesBriefing.com

Rewriting Prime Agent in Rust

Hacker News •
×

Rewriting Prime Agent in Rust Since launching Prime Agent in August, downloads exceeded 300,000 and token processing surpassed 8 trillion. Today, the team ships a faster, cleaner version rewritten from the ground up in Rust. Over two weeks, Prime Agent orchestrated a swarm of over 2,000 agents to rewrite itself end-to-end, operating across 10,000+ Prime Sandboxes with over 200 billion tokens from Prime Inference's GLM-5.3 endpoint.

The rewrite stress-tested multi-agent capabilities, including sandbox and inference infrastructure for large-scale agent swarms, autonomous research, and reinforcement learning. To ensure feature parity, Prime Agent used subagents to topologically sort dependencies, with finite state machines structuring looped computations and correctness checks. The code architecture was rewritten for easier maintenance.

Runtime benchmarks and real traces were used to hillclimb performance metrics and triage bugs. Now, Prime Agent runs faster and uses fewer resources than most coding agent harnesses. The Rust implementation processed 192.99B tokens with 1,981 agents at depth 3, while TypeScript handled 35.70B tokens with 228 agents.

Prime Agent runs faster and uses fewer resources than most coding agent harnesses. Why Rust: TypeScript helped ship quickly, but optional types disappear at runtime, errors travel as unchecked exceptions, and CPU-heavy work competes with keyboard input on a single event loop. Every process pays for a JavaScript runtime and garbage collector.

Rust suits the goal of shipping fast while holding code to a higher standard as it grows. Performance gains come from native code without a garbage collector, per-session worker processes, and startup improvements. Concurrency benefits from Rust's Send and Sync traits, allowing the compiler to check data movement between threads.

Compile-time guarantees from exhaustive enums, ownership, and lifetimes rule out whole classes of bugs. Additional rewards include Windows support, session crash isolation, and a more consistent daemon protocol. The goal was for agents to perform the rewrite autonomously with minimal human intervention.

Human work focused on setting up verification to enable autonomous deployment at scale, following previous work on automatic Rust translation. Each specification covered different kinds of parity: TUI parity compares TypeScript and Rust binaries side-by-side against the same scripted model, diffing terminal frames. Harness parity diffs session transcripts and model provider requests.

Protocol parity checks all daemon protocol message types against the TypeScript implementation. Feature parity involved component-by-component auditing of the TypeScript product. With objective checks ensuring consistency across APIs and protocols.

Source: Hacker News · Summarized by HeadlinesBriefing