跪拜 Guibai
← Back to the summary

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

I've been building AI products as a startup founder recently, and I've also been sharing high-value AI open-source projects on this account. Today I'll take everyone on a deep dive into an open-source AI Agent: Prime Agent. It's open-sourced by Prime Intellect, built around two core abstractions as a long-horizon programming agent: Recursive Language Model (RLM) + Continual Harness.

Let me skip the fancy jargon and break it down for you in plain language, to see what makes it able to "self-evolve."

Honestly, the most noteworthy thing about this project isn't how fast it runs, but that it's the first time I've seen an Agent that can "understand itself better the more it's used." Below I'll go from the most core self-evolution mechanism all the way to how to get started.

一、First, the pain point: why AI coding agents get "messier as they work"

Anyone who uses AI coding agents has probably had this feeling: in a single conversation it's pretty smart, but once you get into long-horizon, multi-step engineering tasks, it slowly starts to "drift." The context gets longer, state gets messier, and it runs off track from the goal; subtasks get split up with no coordination, experience doesn't accumulate, and every time you're starting from scratch.

Engineers feel this most deeply: a task often requires modifying a dozen files, running tests many times, and in the middle you might need to switch between several agents. Once the context gets long, the plan decided earlier gets forgotten, and changes end up diverging from the original design. This experience of getting "messier as you work" is honestly a turn-off after a while.

It's like hiring a very smart intern, but the intern forgets everything they learned yesterday every time they come to work, and you have to explain things over and over. It's not that the agent lacks ability, it's that it "can't remember, can't grow."

Prime Agent's solution is different: it doesn't let agents use-and-forget, but instead makes the agent itself a readable, writable, self-improving object - work done becomes skills, pitfalls encountered become memories, ready to be reused next time.

Many agents on the market claim to have "memory," but most simply pile chat history together, still unable to distinguish what's important. Prime Agent is different: it treats memory, skills, and sub-agents as genuinely manageable "assets," so work done can settle into capabilities that get reused directly next time.

二、Core mechanism: the agent self-evolves

This is the confidence behind calling it "self-improving," and the core is the Continual Harness. It abstracts prompts, memory, skills, and sub-agent specifications all into "state" that can be added, deleted, modified, and queried. After an agent finishes a task, it can write experience into skills, lessons into memory, and codify collaboration patterns into sub-agent specs, saving them for direct use next time.

As an analogy, a normal agent is like a recent graduate who learns fast but forgets fast; Prime Agent is more like an experienced veteran with a desk and notebook - after each review it writes key points into its own "work manual," and next time it starts, the pitfalls to watch for and processes to follow are all waiting there.

Not a single model weight changes, yet the agent's behavior quietly improves. You can think of it as: every time it finishes a task, it updates its own "work manual," and it gets smoother with use.

It divides agent state into four layers by visibility and persistence: model weights, active context, REPL with sub-agents, and on-disk historical memory and skills. Each layer advances with a different mechanism - fine-tuning changes weights, compaction changes context, the agent itself adds and deletes values in the REPL, and distillation updates memory and skills. Understanding these four layers explains why it can "self-evolve."

三、Kernel + everything-as-plugin abstraction

Digging further in, its design is actually very clean, just two threads.

To keep long sessions from "blowing up memory," it has its own compaction mechanism: when context approaches a threshold, it spawns a dedicated sub-agent as a "garbage collector" to clean out unimportant parts of history and distill key information. Meanwhile, sessions are stored as append-only JSONL logs, enabling retrospection, forking, and recovery from snapshots after a process crash.

One thread manages "compute," via RLM (Recursive Language Model). The model uses a persistent IPython interactive kernel as its only tool, spawning sub-agents as a function call - anytime you can await rlm("help me review this module") and spawn a swarm of sub-agents to work in parallel. Each sub-agent has its own context, kernel, history, and workspace; the parent agent continues its own work immediately after delegating, and results come back asynchronously through a message queue.

One thread manages "information," via the Continual Harness reading trajectories across turns, writing execution evidence back into memory and skills. The whole run loop is: receive task → write code in the REPL, call tools, spawn sub-agents → record results and trajectories into history → distill experience into memory and skills across turns → another round. The longer it runs, the more it understands your project.

These two threads combined say one thing: the model handles "thinking," the framework handles "remembering," each doing its own job and coordinating with the other. The thinking part goes to RLM, writing code in the REPL and spawning sub-agents; the remembering part goes to the Continual Harness, writing each round's experience back into state across turns. Precisely because "compute" and "information" are managed separately, it can run long tasks fast without losing things.

四、How to use it

Installation is simple, one command:

curl -fsSL https://app.primeintellect.ai/prime-agent/install.sh | sh

On Windows there's also a one-line PowerShell installer, and you can install via homebrew too. Install size is only a few dozen MB. After install, you have the terminal-based agent - no extra SDK needed, no code changes needed, just hand it a repository URL.

You can watch which sub-agents it spawned at any time, see what it's currently working on, and even drill into any level of the session to watch it work and intervene. Sessions are held by a background daemon, so you can suspend and reconnect at any time without interrupting execution; if it crashes, it recovers from snapshots and continues the original conversation.

五、Real results: it rewrote itself in Rust

Hard data is more convincing. Two months after release, downloads have exceeded 300K, with over 8 trillion tokens processed cumulatively. The most hardcore part was the self-rewrite: the team used 2000+ sub-agents running on 10,000+ sandboxes over two weeks to rewrite the project entirely from TypeScript to Rust. During that time, the code was written by agents, reviewed by agents, and validated by agents; humans only set direction and reviewed results.

After the rewrite: cold-start input-ready latency dropped from ~736ms to 51.9ms (about 14x faster); post-startup memory dropped from ~1130MB to 237MB (an 80% saving). The paper reports ARC-AGI-3 scores going from 30% to 95.5%, and on long-context coding, GPU kernel generation, and simulator building tasks, it matches or exceeds Claude Code, Codex, and Pi.

More notably, this self-rewrite wasn't a one-off performance, it was refined into a product capability: the team decomposed the entire rewrite into individual finite-state-machine-style tasks, with planning, implementation, review, and validation each handled by a dedicated agent, separating generation from verification - the code writers and the fault-finders used different models and different contexts to prevent "blowing one's own trumpet."

六、Application scenarios (personal opinion, for reference)

Where it truly excels is long-horizon, multi-step work that needs an agent on duty for extended periods while continuously accumulating experience: large-scale code refactoring and migration, long-running training and benchmark testing, and complex tasks with multiple parallel agents. For product teams building RAG, long-document agents, and multi-agent collaboration, its approach of "decoupling the runtime framework from model strategy, with state that can be persisted" is especially worth referencing - cost reduction and efficiency gains are never only about summarization and compression.

For me personally, what's most compelling is its "stability" on long tasks: no need to watch constantly, you can drill into any sub-session mid-way to check or tweak, and afterward the experience carries over to the next project.

But don't expect it to be universal: if you just write a few lines of code occasionally or handle short, quick requirements, the advantages of its "self-evolution" never show, and there's a bit of a learning curve. The more measured statement is: it's very distinctive on "long-horizon, collaborative, persistable" tasks and worth following long-term.

七、Reflection and thoughts

Human-AI collaboration is the inevitable direction of AI development. Many agent frameworks are still busy being compatible with a hundred models and piling on flashy features, but Prime Agent focuses effort on "letting the agent grow skills itself" - using a readable, writable, self-improving framework to turn large-model capabilities into controllable, rollback-able, persistable development productivity.

At the end of the day, tools change, models change, but "letting AI accumulate experience and serve real work" doesn't go out of style. If you're working on RAG, long-document agents, or multi-agent collaboration, I'd suggest reading its source code and paper - it's very clear on architecture boundaries, state layering, and the self-improvement loop.

The lesson it gives us: to judge whether an agent framework is worth investing in, don't just look at how flashy the demo is - look at whether it can hold state steady in real long-horizon scenarios, persist reusable experience, and let you see, modify, and intervene at any time. This approach of "decoupling the runtime framework from model strategy, with persistable state" is also instructive for long-document and long-context agent design. If anyone has hit pitfalls in agent experience persistence or multi-agent collaboration, or has implementation details they'd like to discuss, you're welcome to talk.

Comments

Top 2 from juejin.cn, machine-translated. The original thread is authoritative.

徐小夕

Keep sharing

OnceSure

Obvious AI