跪拜 Guibai
← All articles
Vue.js · GitHub · Frontend

Prime Agent rewrote its own codebase from TypeScript to Rust, using 2,000 sub-agents over two weeks

By 徐小夕 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Long-horizon coding agents fail because they can't hold state across runs; Prime Agent's four-layer state model and compact-and-distill loop directly targets that failure. A two-week, 2,000-agent self-rewrite shipped a working Rust migration, so the approach is credible for any team whose agents need to accumulate experience rather than restart from zero.

Summary

Prime Agent pairs a recursive language model (RLM) with a continual harness. The RLM runs on a persistent IPython kernel and spawns sub-agents as awaitable function calls; the harness treats prompts, memory, skills, and sub-agent specs as readable, writable state that accumulates across runs. State is organized in four layers, from model weights down to on-disk history, each advanced by its own mechanism: fine-tuning, compaction, in-session edits, and distillation. A compaction sub-agent acts as a garbage collector when context nears its limit, and sessions log to append-only JSONL for replay and crash recovery.

The headline result is the self-rewrite. Over two weeks, Prime Intellect ran 2,000+ sub-agents across 10,000+ sandboxes to port its own codebase from TypeScript to Rust. Agents wrote, reviewed, and validated the code; humans only set direction and checked outcomes. Cold-start input-ready latency fell from roughly 736ms to 51.9ms, and post-startup memory dropped from about 1130MB to 237MB. The accompanying paper reports ARC-AGI-3 scores jumping from 30% to 95.5%, with long-context coding, GPU kernel generation, and simulator building matching or exceeding Claude Code, Codex, and Pi.

The rewrite wasn't a one-off: the team packaged it as a product workflow, decomposing the migration into finite-state-machine tasks with separate agents for planning, implementation, review, and validation. Generators and reviewers used different models and different contexts so verification stayed independent from generation. Downloads passed 300K two months after release, with over 8 trillion tokens processed.

Takeaways
— Downloads exceeded 300K within two months of release; cumulative token processing passed 8 trillion.
— The self-rewrite ran 2,000+ sub-agents across 10,000+ sandboxes over two weeks, migrating the codebase from TypeScript to Rust.
— Cold-start input-ready latency fell from ~736ms to 51.9ms, roughly a 14x improvement; post-startup memory dropped from ~1130MB to 237MB, about an 80% saving.
— In the paper, ARC-AGI-3 scores rose from 30% to 95.5%, and long-context coding, GPU kernel generation, and simulator building matched or exceeded Claude Code, Codex, and Pi.
— State is organized in four layers, from model weights and active context down to REPL sub-agents and on-disk history, each advanced by a different mechanism.
— Context compaction spawns a dedicated sub-agent as a garbage collector when the context approaches its limit; sessions log to append-only JSONL for replay and crash recovery.
— Install is a one-line curl command, with PowerShell and homebrew also supported; the package is a few dozen MB and requires no SDK or code changes.
— The rewrite workflow was productized as finite-state-machine tasks: planning, implementation, review, and validation each handled by a separate agent, with generators and reviewers on different models and contexts.
Conclusions

The self-rewrite was organized so that code generators and fault-finders ran on different models with separate contexts; that separation of generation from verification is a simple, transferable pattern for any agent pipeline.

Prime Agent's design bets on state management rather than longer context windows; the four-layer split explains why many agents drift on long tasks, since most only manage one or two of those layers.

The 30% to 95.5% ARC-AGI-3 jump comes from the team's own paper, so the number should carry the usual self-reported benchmark caveats.

Concepts & terms
RLM (Recursive Language Model)
A model that uses a persistent IPython kernel as its single tool and treats sub-agent spawning as an awaitable function call, with results returning asynchronously through a message queue.
Continual Harness
The framework that turns prompts, memory, skills, and sub-agent specs into readable, writable state, so an agent's experience persists across runs without changing model weights.
Compaction
A mechanism that triggers a dedicated sub-agent to garbage-collect unimportant context and distill key information when the context window approaches its limit.
State layering
Prime Agent's four-layer model of agent state, from model weights and active context down to REPL sub-agents and on-disk history, each advanced by fine-tuning, compaction, in-session edits, or distillation respectively.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗