SnackOnAI Engineering | Senior AI Systems Researcher | Technical Deep Dive | October 26, 2026
The promise: by the end of this issue you will understand how Prime Intellect used more than 2,000 agents to port a production coding agent to Rust, how it proved the port behaved the same, and which part of the result came from the language versus the engineering loop.
The fence: we cover the Prime Agent repository at its October 24, 2026 head, Prime Intellect's Rust rewrite post, and the Prime Agent paper for the harness design. We skip the paper's benchmark results except as context, and we did not rerun the performance suite; our numbers decompose the published ones and measure the source tree.
What It Actually Does
Prime Agent is Prime Intellect's MIT licensed coding and research agent, built around a Recursive Language Model (RLM) design: the model works inside a persistent Python REPL, treats context as variables, and spawns real child agents with rlm.spawn(...). A daemon keeps sessions, REPL state and subagents alive when the terminal disconnects.
The original harness was TypeScript. On October 9, 2026, Prime Intellect shipped a Rust rewrite produced mostly by Prime Agent itself.
Property | Value |
|---|---|
Rewrite effort | 2,209 agents, 16,758 agent to agent messages, 228.7B tokens (GLM-5.3 on Prime Inference) |
Infrastructure | Two 8 core CPU nodes running 100+ concurrent subagents each; 10,000+ Prime Sandboxes for builds and checks |
Timeline | Two weeks autonomous rewrite and parity, then weeks of human reviewed finishing, then a three day performance hillclimb |
Codebase today (our count) | 615,943 lines of Rust in 10 crates; 217,605 of them in test paths; a 31,658 line Python REPL runtime |
Safety |
|
Reported gains vs TypeScript | Cold start to input ready 14.2x faster; large session memory 79% lower; install 2.9x smaller |
Prime Intellect's stated reasons for Rust: TypeScript types vanish at runtime, errors are unchecked exceptions, and heavy rendering competes with keystrokes on one event loop. Rust adds compile time thread safety (Send, Sync), exhaustive enums, and no garbage collector in a daemon that runs one worker process per session.
The Architecture, Unpacked
Two systems matter here: the agent factory that did the rewrite, and the Rust product it produced.

Caption: Generation and verification never share an agent. The implementer cannot approve its own code, and nothing merges without a fresh sandbox run against the TypeScript oracle.
Four design decisions do the work.
One: humans build the referee, agents play the game. The first phase was human work: parity specs and differential harnesses that let agents check themselves. Prime Intellect's stated goal was a rewrite "with as little human intervention as possible," and the checks are what made that possible.
Two: four kinds of parity. TUI parity runs both binaries against a scripted model and diffs terminal frames. Harness parity diffs session transcripts and the requests sent to model providers. Protocol parity checks every daemon message type. A feature audit covers what scripts cannot reach.
Three: adversarial, cross model review. The reviewer uses a different model with a separate context and is told to look for reasons the change is wrong, because a code writing agent is biased toward its own code.
Four: a hillclimb with no target. After parity, 228 agents ran three days of benchmark driven optimization in a fresh 4 core, 8 GB sandbox: profile, run current and candidate in alternating order, get two reviews from different frontier models, merge, rebaseline. "We deliberately gave the loop no numeric targets, since a fixed threshold tends to become a stopping point."
The Code, Annotated
First, the CLI differential test, from crates/pa-cli/tests/differential_cli.rs. The TypeScript binary is the oracle; any byte of difference fails the test.
fn differential_corpus_matches_ts_binary() {
let Some(ts) = ts_binary() else {
eprintln!("SKIPPED: TS prime-agent binary not found (set PA_TS_BINARY)");
return; // ← the oracle is optional: no TS binary, no check
};
let rust = PathBuf::from(env!("CARGO_BIN_EXE_prime-agent"));
...
for case in CORPUS { // 194 argv cases: help, typos, parser errors, MCP...
let ts_out = run(&ts, case, &ts_sandbox);
let rs_out = run(&rust, case, &rs_sandbox);
let ok = ts_out.exit_code == rs_out.exit_code
&& normalize(&ts_out.stdout, &sandbox_roots)
== normalize(&rs_out.stdout, &sandbox_roots) // ← THIS is parity: bytes, not vibes
&& normalize(&ts_out.stderr, &sandbox_roots)
== normalize(&rs_out.stderr, &sandbox_roots);
...
Caption: Exit codes, stdout and stderr must match after normalization. Even typo suggestions like help schedul are part of the contract.
Second, the normalizer, from the same file. This is where intentional divergence gets written down.
fn normalize(text: &str, sandbox_roots: &[&Path]) -> String {
let mut text = text.to_string();
for root in sandbox_roots { // per binary temp dirs leak into error messages
text = text.replace(&root.display().to_string(), "<SANDBOX>");
}
text = normalize_docs_paths(&text); // each binary's own install dir
// The `prompt` dump command is a Rust-first addition the TS product has
// not adopted yet; normalize its help rows out ...
text = normalize_prompt_command_rows(&text); // ← THIS is where "same" gets redefined
normalize_versions(&text)
}
Caption: Every normalizer is a documented exception to parity. Once the Rust product starts adding features, the oracle starts needing carve outs.
Third, the guardrails agents had to satisfy, from the workspace Cargo.toml.
[workspace.lints.rust]
unsafe_code = "forbid" # memory safety is a compile error, not a code review comment
[workspace.lints.clippy]
# The pedantic gate the five clippy campaigns earned (pa-daemon #3029,
# pa-cli #3050, pa-core #3093, the small crates #3110, pa-tui #3134)
pedantic = "warn" # CI's -D warnings turns these into errors
redundant_clone = "warn"
clone_on_copy = "warn"
Caption: When agents write most of the code, strict compilers become the cheapest reviewer. Only pa-core and pa-types opt out of forbid, for process, termios and lock file bindings.
Fourth, our decomposition of the published numbers.
rows = { # (TypeScript, Rust before hillclimb, Rust after)
"cold start input-ready (ms)": (736.1, 293.3, 51.9),
"large-session RSS (MB)": (1130.0, 554.9, 237.3),
"installed size (MB)": (172.1, 206.7, 59.6),
"agents view switch (ms)": (78.0, 118.8, 12.8),
}
# metric rewrite hillclimb total hillclimb share of gain
# cold start input-ready 2.51x 5.65x 14.18x 65%
# warm start input-ready 2.00x 6.68x 13.34x 73%
# large-session RSS 2.04x 2.34x 4.76x 54%
# installed size 0.83x 3.47x 2.89x 117% (rewrite made it worse)
# agents view switch 0.66x 9.28x 6.09x 123% (rewrite made it worse)
Caption: The translated Rust was 2x to 2.5x faster to start and lighter on memory, but bigger and slower on two of five metrics. The three day hillclimb produced most of the final gain on every metric.
It In Action
Input: one port task from the factory's queue, such as reproducing the CLI's help and error surface exactly.
Step one, plan. The planner records the TypeScript behavior as ground truth, writes the spec, and defines the parity check: 194 argv cases in the CLI differential corpus, from --version to help schedule bogus.
Step two, implement. The implementer writes Rust in its own git worktree, against the shared pa-types protocol definitions so client, daemon and workers compile against the same messages.
Step three, review. A reviewer on a different model, with fresh context, reads the diff adversarially. Findings send the task back to the implementer.
Step four, verify. A verifier compiles and runs tests plus the differential corpus in a fresh Prime Sandbox. Both binaries run each case in separate temp directories; outputs are normalized and compared byte for byte.
Step five, merge and repeat. The root agent merges and unblocks dependent tasks. Across the whole rewrite, that loop ran through 1,981 agents and 192.99B tokens, about 97M tokens per agent.
Output: a merged, parity checked change. Then the hillclimb took the product from the left column to the right:
Metric (fresh 4 core, 8 GB sandbox, inference excluded) | TypeScript | Rust, translated | Rust, hillclimbed |
|---|---|---|---|
Cold start to input ready | 736.1 ms | 293.3 ms | 51.9 ms |
Large session RSS (10 MiB session) | 1,130 MB | 554.9 MB | 237.3 MB |
Installed size | 172.1 MB | 206.7 MB | 59.6 MB |
Agents view switch | 78.0 ms | 118.8 ms | 12.8 ms |
Caption: 144 hillclimb experiments, 69 merged (48%), about 517M tokens per merged improvement. Most wins came from moving work off startup and render paths, replacing polling with event driven waits, and releasing memory after large loads.
Why This Design Works, and What It Trades Away
Why it works. Porting is the rare software task with a perfect oracle: the old program. Differential testing turns "is this right?" into "is this the same?", which agents can check automatically and at scale. Separating planner, implementer, reviewer and verifier blocks the most common agent failure, grading its own work. Rust's compiler adds thousands of free checks per change, and a one way crate graph keeps 600,000 lines navigable for agents: Prime Intellect reports the largest file is about 2,500 lines, against about 15,000 in the TypeScript.
What it trades away.
Coverage is the ceiling. Prime Intellect says parity checks only verified what they exercised; real bugs surfaced through internal use and beta feedback, and closing gaps took weeks of human reviewed fixes.
Token cost. 228.7B tokens. The post gives no dollar figure; at an assumed $0.50 to $2 per million blended tokens that is roughly $114K to $457K.
Code volume. 616,000 lines of Rust is a large surface to own, even with 35% of it in tests.
Measurement scope. Every number excludes inference, which dominates real agent latency. A 52 ms start matters for feel, not for task throughput.
Technical Moats
The factory, not the code. Sandboxes at 10,000+ scale, a self hosted inference endpoint serving 200B+ tokens in two weeks, and an RLM harness that can coordinate 2,000+ agents through messages. Few teams can replicate that loop.
Differential oracles for terminal software. A recording mock terminal over a real pty, scripted models, and frame diffs are hard to build and rarely open sourced.
A self improving harness. The Continual Harness lets Prime Agent persist evidence backed prompt, memory and skill updates, so the tool that did the port also learns from it.
Distribution. 300,000+ downloads before the rewrite gave real beta traffic whose logs agents could triage.
Contrarian Insights
Insight One: the language bought a 2x; the measurement loop bought the rest. Translating TypeScript to Rust gave 2.5x faster cold start and half the memory, while making the install 20% bigger and view switching 52% slower. The three day hillclimb then delivered 5.7x on cold start, 9.3x on view switching and 3.5x on install size. On every metric, the majority of the improvement (54% to 123% of the log scale gain) came after the rewrite. Teams planning a Rust port for speed should budget for the profiling loop, because translation alone does not deliver the headline.
Insight Two: the parity oracle has an expiry date. The differential CLI test returns early, printing "SKIPPED," when the TypeScript binary is not installed, and its normalizer already strips a Rust only command so the outputs still compare. That is reasonable during migration. But as TypeScript is retired and Rust diverges, parity tests degrade into no ops and carve outs. The real long term asset is converting each parity case into a native Rust behavioral test before the oracle disappears.
Surprising Takeaway
The rewrite consumed about 313,000 tokens for every line of Rust in today's repository, sustained at roughly 160,000 tokens per second for two weeks. Writing code was the cheap part. Most of the budget went to planning, adversarial review, sandboxed verification and retries, the machinery that proves the code behaves the same.
TL;DR For Engineers
Prime Agent's Rust harness was produced by 2,209 agents and 228.7B tokens, with a planner, implementer, cross model reviewer and fresh sandbox verifier per task.
Parity came from TUI frame diffs, transcript and provider request diffs, protocol checks and a feature audit against the TypeScript binary.
Translation alone: 2.5x faster cold start, 2x less memory, but bigger install and slower view switching; a three day agent hillclimb produced most of the final 14x.
unsafe_code = "forbid", pedantic clippy as errors and a one way crate graph are the guardrails that make agent written Rust reviewable.Turn parity cases into native tests before you retire the old implementation.
Explain It Like I'm New
Imagine translating a long, complicated instruction manual from one language into another, and the translation has to work exactly like the original. Not roughly the same, exactly the same, down to every error message and every screen.
That is what Prime Intellect did with its AI coding assistant. The assistant was originally written in TypeScript, a popular but loosely checked programming language. The company wanted it in Rust, a stricter language that catches many mistakes before the program even runs and tends to make software faster and lighter.
Instead of assigning engineers, they had the assistant rewrite itself, using more than two thousand AI workers. Some planned each piece, some wrote it, some reviewed it looking for mistakes, and some tested it in clean environments. Humans built the most important part: automatic tests that ran the old and new versions side by side and flagged any difference.
The surprising lesson is that writing the new code was the easy part. Proving it behaved the same took most of the effort, and the biggest speed gains came afterward, when AI workers spent days measuring and tuning. This points to a future where AI does much of the coding, and human expertise shifts to designing the tests that keep it honest.
See It In Action
Prime Agent in Rust, Prime Intellect. primeintellect.ai/blog/prime-agent-rust. The full write up with the factory design, parity types, hillclimb loop and benchmark tables.
Prime Agent repository, Prime Intellect on GitHub. github.com/PrimeIntellect-ai/prime-agent. Browse the differential tests under
crates/pa-cli/testsand the 73 helper and behavior check scripts underscripts/.Recursive Language Models, Prime Intellect. primeintellect.ai/blog/rlm. The prompt as a variable and recursive subagent design the Rust runtime preserves.
Prime Agent's RLM harness explained, Daniel Vaughan. codex.danielvaughan.com. A practitioner comparison of Prime Agent's persistent REPL and subagents against Codex CLI's architecture.
Community Conversation
Digg AI roundup of X reactions, Prime Agent Rust discussion. Team members Kevin Thomas and Seth Karten framed the rewrite as a stress test of agent swarms; Florian Brand argued open models are more capable than benchmarks suggest; Sankalp joked about a "universal basic port to rust era."
Runtime Wire, 2,000 agents rewrote its coding agent in Rust. Notes that all benchmarks exclude inference and are company reported, so they do not show end to end gains for users.
AlphaSignal, Prime Intellect sent 2,000 agents to rewrite Prime Agent. Covers the scale of the swarm and the startup gains.
AI Weekly, Prime Agent lifts ARC-AGI-3 from 30% to 95.5%. On the harness paper: the authors attribute the jump to measuring closer to the model's maximal capability, a reminder that harness design shapes benchmark scores.
Agent Written Systems Code Lives or Dies by Its Oracles
Prime Agent's Rust rewrite is the clearest public case of agents porting production systems software, and its lesson is not "use Rust." The language contributed a solid 2x and a strict compiler. The rest came from engineering: humans building differential oracles, a factory that never lets an agent grade itself, and a target free hillclimb that found 69 real improvements. If you plan to have agents rewrite your stack, spend your first weeks on the tests that define "the same," and your last days letting agents measure.
References
Prime Agent: A Self-Improving RLM Harness, Karten et al. The persistent REPL, recursive subagents and Continual Harness behind the agent that did the port.
Continual Harness, the paper linked from the Prime Agent README. Durable, evidence backed updates to prompts, memories, skills and subagent specs.
Is Rust Used Safely by Software Developers?, Astrauskas et al. How real Rust code confines
unsafe, the pattern Prime Agent enforces withforbid.SWE-bench: Can Language Models Resolve Real-World GitHub Issues?, Jimenez et al. The test based verification idea that differential parity extends from issues to whole programs.
Prime Intellect used 2,209 agents and 228.7B tokens to port Prime Agent from TypeScript to Rust, with a planner, implementer, cross model reviewer and sandboxed verifier per task and differential parity tests against the TypeScript binary. Our decomposition shows the translation itself delivered about 2x; a three day agent hillclimb produced most of the 14x startup and 79% memory gains.
Sponsored Ad If you enjoy practical AI insights, check out SnackOnAI and support the newsletter by subscribing, sharing, and exploring our sponsored ad—it helps us keep building and delivering value 🚀
Buying an AI agent is the easy part
In Front's research, 47% of leaders say their agents already handle customer interactions without a human, at least sometimes. Of those, 79% have had a complaint caused by the agent's own work.
Running Agents in Customer Work is a webinar series for the support, success, and ops leaders making the calls. Two live sessions left, both at 10 a.m. PT: Oct. 27, who's accountable when your agent gets it wrong, and Nov. 3, what your agent's resolution rate doesn't tell you.
Register. One sign-up covers every session, recordings included.


