# Prime Agent: A self-improving RLM agent
**作者**: Prime Intellect
**日期**: 2026-08-07T06:21:52.000Z
**来源**: [https://x.com/PrimeIntellect/status/2085612369154281546](https://x.com/PrimeIntellect/status/2085612369154281546)
---

Today, we are launching Prime Agent, our self-improving coding harness designed around two abstractions, the Recursive Language Model (RLM) [citation] and Continual Harness [citation]. Modern harness designs were built around the capabilities of earlier generations of models, and they do not reflect what frontier models can do today: fixed tool-calling schemas and context compaction force the model to work around its own scaffolding instead of leveraging it. Static, hand-engineered sub-agents, prompts, skills, and memory are set once at design time and never adapt to what the agent learns while running. We believe that harnesses should instead extrapolate on current model capabilities toward the next frontier of reasoning patterns.
Prime Agent is built around this principle through two main abstractions:
1. The Recursive Language Model (RLM) treats context as a variable and subagent delegation as function calls inside a REPL. The persistent REPL gives the model programmatic access to its history, sub-agents, and tools, allowing it to write language model programs as actions over its own context. This design allows the agent to process arbitrarily long sessions without losing access to its own past information stored in variables.
2. Continual Harness treats the harness's own state, abstracted as its prompts, skills, memory, and sub-agents, as something the agent can create, read, update, and delete (CRUD) from its own trajectory. When combined with agent-to-agent communication, this mechanism enables orchestration across sub-agents and even across Prime Agent sessions. For example, Prime Agent can spawn persistent sub-agents, message them later in the trajectory, and communicate directly with a different Prime Agent session.
These abstractions are powerful for bootstrapping model capabilities. Prime Agent is built to be effective as a general coding assistant, as a default runtime for long-horizon autonomous evaluation, and as a collaborator for research and autoresearch.
Prime Agent is fully open-source, and can be installed via:
> curl -fsSL https://app.primeintellect.ai/prime-agent/install.sh | sh

## Prime Agent
The performance of agent harnesses are tied to both the design of the harness and the capability of the model trained around the harness. We designed Prime Agent to be immediately usable with modern open and closed frontier models, while also providing a feature set that we expect to provide further performance gains as newer generations of models are trained around it.
At its core, Prime Agent is designed around programmatic tool and sub-agent calling. Models in Prime Agent use a persistent IPython kernel as their only tool. Other standard harness features are called as functions in the kernel, including sub-agents, which are each implemented as another prime-agent instance.
## Prime Agent's Architecture

RLM and Continual Harness are the two core abstractions; sub-agent CRUD plus Agent2Agent messaging compose them into orchestration.
Background Daemon and Agents View. The default view is a text-user interface (TUI) similar to other coding agent harnesses. By default, IPython actions made by the agent are condensed for brevity, but can be expanded to view actions made by the harness. Sub-agents launched in the REPL can also be accessed below the user chatbox.

Prime Agent runs a background daemon that owns all live agent sessions over a local socket. You can attach and detach from the session without affecting the underlying agent loop. Each root session tree runs in a recoverable worker process; if a worker crashes, the daemon recovers it from the session JSONL and kernel state snapshot.
The Agents View allows you to see and select other live sessions from the daemon. It can be opened by pressing the Left Arrow key (←) on an empty prompt, and lists sessions that are currently running, idle sessions with the daemon still active, and inactive sessions that are currently not loaded in memory. Any of these chats can immediately be entered and interacted with, and pressing space allows users to chat with a session in any state, including steering and queuing of prompts and commands such as /compact.
The Agents View is constructed as the central connecting point between agents and subagents, recursively. Any agent is discoverable in an Agents View. Users navigate from an Agents View into an agent's chat, then into the Agents View of its subagents, into a subagent chat, and so on.
Because subagents share the same Running-Idle-Inactive state machine as the root agents, they can be removed from memory after 30 minutes of inactivity, and the moment a user or agent addresses any of them, they are reloaded from disk. In highly nested chats, this can save a lot of memory.

Session and Context Management. The entire session history of the agent is stored as append-only JSONL files on disk. Each line is a JSON entry, which can include messages, model switches, compaction summaries, or extension entries. Branching, forking, and cloning all happen within the same file by moving the leaf pointer. The full history is always recoverable through /tree.
Compaction happens when the context hits a threshold or directly by the agent in the REPL with compact.run(). Compaction is primarily used to clean the main context of the agent, but the full history, including past compactions, can be accessed programmatically in the IPython kernel when needed.
The introduction of the REPL requires additional work to manage the IPython state. We asynchronously compact and clean the kernel simultaneously, using a spawned agent to act as a garbage collector. This is necessary to avoid REPL memory built up for each agent.
RLM and Programmatic Tool-Calling (PTC)
Prime Agent relies on the IPython kernel as its REPL that persists over the session, which it can invoke every turn. On initialization, the kernel pre-imports each skill / tool as a module, including the rlm for recursive programmatic sub-agent calling.
The rlm is an asynchronous function, meaning the model can freely invoke and parallelize sub-agent calls in code. Spawning a subagent (e.g. await rlm("sub-task")) launches a full session with its own model, IPython kernel, session tree, and conversation history. It returns immediately, because all subsequent communication between agents happens through the agent_message.send(...) tool.
There are several useful primitives that Prime Agent can choose to launch in this way, such as fanning out sub-agents in parallel, or launching background work.
> # Parallel fan-out — rlm() returns at task admission with a child handle,
> # never the child's answer; results arrive as agent_message replies.
> auth = await rlm("Summarize the authentication flow in auth/. Reply to me when done.", name="auth-expert")
> api = await rlm("Summarize the updated HTTP API layer in src/. Reply to me when done.", name="http-expert")
> # ... continue independent work; each child replies via
> # agent_message.send(..., receiver_role="parent") when finished ...
> # Steer or extend a child mid-flight by role + name
> await agent_message.send(
> "Also cover middleware error handling.",
> receiver_role="child",
> receiver_name=api.name,
> )
As models continue to improve, new invocation patterns over tool calls and sub-agents will emerge. We expect future generations of models to rely less on hand-holding prompts and more on this kind of direct, programmatic control.
Orchestration and Multi-Agent Communication
The background daemon manages all live Prime Agent sessions. Prime Agent also enables Agent-to-Agent (A2A) messaging through the daemon, letting any Prime Agent session message any other Prime Agent session using the same mechanism used for messaging persistent sub-agents. This allows for easy orchestration to manage the progress of sub-agent swarms and communication regarding shared resources directly between the affected agents. To prevent undesirable communication across independent sessions, multi-agent communication in Prime Agent is limited to its nuclear family, meaning parent, sibling, or child processes.
> # Spawn a named child; the handle returns at admission.
> handle = await rlm("Find what's wrong in this auth-flow. Reply to me with your findings.", name="auth-reviewer")
> # ... the child's findings arrive as a parent-role reply, not a return value ...
> # Later (survives compaction and kernel restarts): recover the retained child.
> children = await rlm.list_subagents()
> auth_child = next(c for c in children if c.session_name == "auth-reviewer")
> # Send a follow-up turn into the same retained child session.
> await agent_message.send(
> "Follow up: identify the main edge cases and any likely bugs.",
> receiver_role="child",
> receiver_name=auth_child.session_name,
> mode="follow_up",
> )
Prime Agent supports persistent sub-agents through its RLM-native runtime, meaning a sub-agent's own session directory, context, IPython kernel, and session history persist even after the initial sub-agent call has finished. Prime Agent can send further messages to continue a persistent sub-agent by accessing its unique session identifier, all from its IPython kernel.
## Self-Improvement via the Continual Harness
Prime Agent's harness state lives in the persistent IPython kernel as rlm.harness, immediately readable and callable by the agent mid-task, and every change is also written to disk, so it survives across turns and across sessions. Continual Harness formalizes this state as H=(ρ,G,K,M)H=(ρ,G,K,M), prompt, sub-agents, skills, and memory, refined online from the agent's own trajectory without resets.
Each of the four components exposes the same create, read, update, delete surface. create_prompt_note(...), create_memory(...), create_skill(...), and create_subagent(...) each add an entry of that kind, update_X(...) and delete_X(...) mirror them, and list(kind) or get(kind, id) read them back. Skills follow this same surface: authoring a Python-backed skill is a create_skill(...) call carrying a SKILL.md-style reference, the same operation as adding a memory or a prompt note.
> # Create a memory and a skill through the same CRUD surface
> rlm.harness.create_memory("flaky test pattern", "retry three times before failing")
> rlm.harness.create_skill("retry helper", "...", reference={"type": "python", "import": "retry_helper"})
> # Read them back
> rlm.harness.list("memory")
> rlm.harness.get("skill", "retry_helper")
/refine is the self-improving pipeline built on top of this CRUD surface. It reads the agent's own trajectory, the record of what was tried and what happened, and applies the smallest relevant CRUD edit that improves the harness toward better outcomes: updating a prompt note, memory, skill, or sub-agent spec, rather than rewriting the whole harness. Each refinement records its trigger and the outcome it produced, so improvement is evidence-backed rather than arbitrary. Refinement runs in two phases. Planning, the LLM call that proposes the edit, runs in the background and does not block the ongoing conversation. Applying the edit, writing to disk and rebuilding the system prompt, is fast and only briefly blocks at the next turn boundary. The agent can call refine.run() directly whenever it notices a repeated failure or a reusable tactic, not only on a fixed schedule.
> # Schedule a refinement focused on a specific observation
> await refine.run("promote the retry-on-flaky-test pattern to a skill")
> # Both status calls follow the same shape, though refine's plan/apply split
> # means "in_flight" can mean either background planning or the fast apply step
> await compact.status() # tokens, context_window, percent, scheduled
> await refine.status() # pending, in_flight
The base system prompt remains immutable. /refine only edits the harness layer around it. Rollback is supported through prior refinement history, allowing a bad harness update to be reverted by ID.
## Autonomous Mode for Evals
Prime Agent's eval mode combines three complementary mechanisms. A goal sets the overall objective: a persistent objective with an optional token budget that the harness keeps re-prompting the agent to pursue across turns, tracked until the agent explicitly calls goal.complete(). Heartbeats are scheduled cron-style messages injected into the session on a fixed interval, used for regular checks such as monitoring a sub-agent's progress or polling for a training update. Autonomous mode is the continuation mechanism itself, ensuring the agent keeps working toward the goal instead of stopping early once a turn produces no further output. Together, these let a session run unattended for extended periods while remaining bounded by an explicit budget and inspectable through the Agents View.
Autonomous mode is available directly from the CLI with --autonomous, no scripting required. A run can set a completion goal and a turn limit in the same command:
> prime-agent \
> --autonomous \
> --autonomous-gate "npm run check" \
> --autonomous-max-turns 20 \
> "Implement and verify the requested change"
The gate command runs before the session is allowed to finish. A failed gate returns its bounded output to the agent for another attempt, and Prime Agent skips rerunning a failed gate when the workspace has not changed since the last attempt. --autonomous-max-turns, --autonomous-max-tokens, and --autonomous-timeout-ms bound continuations, tokens, and wall-clock time respectively.
## Evaluating Prime Agent
Prime Agent serves as both a coding agent to be used, and a harness design to be evaluated for research. We make special note that while many modern frontier models are trained around a specific harness, currently no model has been trained around Prime Agent or its core feature set.
ARC-AGI 3. ARC-AGI 3 is a popular intelligence benchmark that measures the ability of an agent to perform symbolic reasoning and learn the rules of simulated worlds. We evaluate Prime Agent with autonomous mode over several different frontier models, and compare to their native harnesses. Prime Agent was developed as a CLI coding agent, so the only ARC AGI 3 specific changes are to the task prompt, inspired by the standard prompt setup used in PRO-LONG.
Our best results use Opus 5 in Prime Agent to achieve 95.5% RHAE Best@1, which surpasses the ARC reported human expert baseline of 95.4%. Across three runs, we find that Prime Agent consistently performs well [95.0, 95.2, 95.5] and 99.97% Best@3 with all 183/183 levels complete. Our median score card action replay (95.2%) for ARC-AGI-3 can be found here.

ARC-AGI-3: (left) test-time compute scaling: score vs. output tokens per game. (right) cost scaling: score vs. estimated API cost.
In addition to achieving a higher maximum score over each model's native harness, we find that Prime Agent also does so at a lower overall token usage. Prime Agent saves tokens by programmatically running functions over data rather than spending tokens reading data using tools.
Finally, we note that we evaluated Opus 5 and GPT-5.6 Sol with Claude Code and Codex respectively, and found worse overall performance relative to the official results, so we yield to their official reported numbers instead.
## Long context and long-running tasks

Many difficult tasks in the wild reduce to long context tasks. Our goal is to show that Prime-Agent with open-weights models are a competitive alternative to closed models and harnesses, both as a general agent to be used, and as a baseline harness to be evaluated.

Below, we select a suite of common long-context benchmarks across coding, retrieval, and general long reasoning tasks, and compare Prime Agent to several different popular harnesses. We offload the main context in each harness to a file in memory to start. For closed model harnesses, we use their associated models (i.e., Codex with GPT, Claude Code with Opus) while for Prime-Agent and Pi-mono (with sub-agents), we choose an open-weights model in GLM-5.2.


We generally find Prime Agent to be competitive across a wide range of long tasks, especially against the harness that did not use a model trained around it. Prime Agent especially excels at long-running or long-context tasks, and can competitively run on its own as an autonomous agent. We include a set of focused case studies and experiments on long settings where Prime Agent excels
Creating emulators from scratch. An emulator is software that reproduces another computer system's observable behavior. We evaluate Prime Agent on EmulatorBench, a preview benchmark that tasks agents with constructing emulators in Rust for a variety of game systems. Agents are given a specification of the emulator and a set of diagnostic tests in the form of a verifier.
The correctness of an emulator is given from its ability to mimic the behavior of the target machine. This is measured by human-generated diagnostic programs that inspect the emulator's behavior, such as the CPU flags, PPU timing, and other components. In an effort to minimize the effects of data contamination, we require the agent to build the emulator from scratch in Rust, sandboxed without any reference implementation. We report preliminary results on this long-context coding benchmark averaged over 16 emulator reconstructions, as well as two emulators, the SEGA Genesis and Nintendo Game Boy Color, that Prime Agent successfully reproduces. For Opus, our runs surprisingly failed to solve the tasks despite successful tool-call responses.

EmulatorBench: Score vs. Cost on creating (left) Sega Genesis emulator and (right) Game Boy Color emulator.
Writing GPU kernels. Writing performant GPU kernels is an iterative process that requires repeatedly verifying, profiling, and tweaking code to get correct. We evaluate Prime Agent as a harness for GPU kernel writing on the recently released PMPP-Hard benchmark, a suite of tasks where agents must write performant GPU kernels that pass a suite of correctness checks against KernelGuard, the verification tool used for the official GPU MODE kernel leaderboard.
## A long-horizon case study on games
Autonomously playing video games has become an interesting case study for models and harnesses in how they handle long-horizon decision making. Games often require harnesses to balance information and context across millions of tokens, while also leveraging this information to efficiently take actions and avoid catastrophic states.
Factorio. Factorio is a 2D factory simulation game where agents must mine resources, research technology, and build automated factories to increase the production of these resources. The Factorio Learning Environment (FLE) is an interface for simplifying the observation and action space of an LLM playing Factorio, which we use to connect Prime Agent to the game.
The action and observation space of FLE is a module in Python that is accessed programmatically at every turn. This integrates directly into Prime Agent's IPython kernel. To leverage PTC for sub-agents, we launch four controllable characters in the game.

Prime Agent using subagents and programmatic tool calling to cheat on Factorio by teleporting resources directly into machines.
The primary metric in FLE is production score, which is a weighted average of all materials the agent produces. Prime Agent successfully leveraged /refine to turn failures and successes into memories and skills, respectively. It used its own accumulated experience to design increasingly efficient machine layouts, raising the production score run over run. This allowed Prime Agent to efficiently score in the 100K+ range in production score in a matter of hours.

However, we also observed instances of reward hacking by Prime Agent in FLE. Prime Agent discovered it could bypass Factorio's rules entirely by spawning in resources directly into its assembly machines through RCON commands, even with an explicit heartbeat prompt to remind Prime Agent not to cheat in Factorio. Once it found this exploit, the same refinement loop that had been building legitimate skills turned to building efficient cheating skills instead.
MazeBench. MazeBench is an open-world 3D spatial reasoning environment where the player controls a 3D cube and must solve puzzle rooms within a global maze, while collecting gems. Frontier models are shown to greatly struggle on this task, expending billions of tokens to solve only a fraction of the overall world. We compare Opus 5 and GPT-5.6 Sol with Prime Agent versus their native harnesses, as well as GLM-5.2 with Claude Code. Following the benchmark metrics, we report the unique number of rooms they find, the unique number of states, and the total number of gems, all as a function of their overall token spend.

## Next Steps
Prime Agent is a new paradigm on the design of agent harnesses. Despite strong results over other harnesses, we still notice friction when running Prime Agent with models. This implies that there are huge performance gains still available from training with Prime Agent directly around this harness paradigm, or even the individual RLM and Continual Harness components.
We strongly believe that model-harness co-learning is the dominant paradigm to unlock new capabilities. Many features of Prime Agent are not fully utilized without a trained model, and we believe there are huge performance gains still available from training with the harness directly. We are excited to bring you these new capabilities, all in the open.
We will have a full technical report with further details soon.
## Install Prime-Agent
Prime Agent is fully open-source, and can be installed via:
> curl -fsSL https://app.primeintellect.ai/prime-agent/install.sh | sh
https://github.com/PrimeIntellect-ai/prime-agent
Acknowledgements
Prime Agent is built on top of pi. We thank the authors of pi for their valuable work.
## 相关链接
- [Prime Intellect](https://x.com/PrimeIntellect)
- [@PrimeIntellect](https://x.com/PrimeIntellect)
- [31K](https://x.com/PrimeIntellect/status/2085612369154281546/analytics)
- [citation](https://arxiv.org/abs/2512.24601)
- [citation](https://arxiv.org/abs/2605.09998)
- [open-source](https://github.com/PrimeIntellect-ai/prime-agent)
- [https://app.primeintellect.ai/prime-agent/install.sh](https://app.primeintellect.ai/prime-agent/install.sh)
- [compact.run](https://compact.run/)
- [api.name](https://api.name/)
- [refine.run](https://refine.run/)
- [refine.run](https://refine.run/)
- [ARC-AGI 3](https://arcprize.org/arc-agi/3)
- [PRO-LONG](https://arxiv.org/abs/2607.20064v2)
- [here](https://arcprize.org/scorecards/2af780b4-f2a1-43e9-a794-b23da3cd3f9f)
- [PMPP-Hard](https://blog.sinatras.dev/PMPP-Hard)
- [KernelGuard](https://github.com/gpu-mode/kernelguard)
- [GPU MODE](https://www.gpumode.com/home)
- [Factorio Learning Environment (FLE)](https://jackhopkins.github.io/factorio-learning-environment/versions/0.3.0.html)
- [MazeBench](https://mazebench.com/blog?post=maze-bench-results)
- [open-source](https://github.com/PrimeIntellect-ai/prime-agent)
- [https://app.primeintellect.ai/prime-agent/install.sh](https://app.primeintellect.ai/prime-agent/install.sh)
- [https://github.com/PrimeIntellect-ai/prime-agent](https://github.com/PrimeIntellect-ai/prime-agent)
- [Upgrade to Premium](https://x.com/i/premium_sign_up)
- [2:21 PM · Aug 7, 2026](https://x.com/PrimeIntellect/status/2085612369154281546)
- [31.1K Views](https://x.com/PrimeIntellect/status/2085612369154281546/analytics)
- [View quotes](https://x.com/PrimeIntellect/status/2085612369154281546/quotes)
---
*导出时间: 2026/8/8 12:24:54*
---
## 中文翻译
# Prime Agent:一个自我改进的 RLM 智能体
**作者**: Prime Intellect
**日期**: 2026-08-07T06:21:52.000Z
**来源**: [https://x.com/PrimeIntellect/status/2085612369154281546](https://x.com/PrimeIntellect/status/2085612369154281546)
---

今天,我们推出了 Prime Agent,这是一个具备自我改进能力的编程框架。它围绕两种抽象概念构建:递归语言模型(RLM)[引用] 和持续框架 [引用]。现代框架的设计是基于前几代模型的能力构建的,无法反映当今前沿模型的真实能力:固定的工具调用模式和上下文压缩迫使模型去迁就其自身的脚手架,而不是利用它。静态的、手工设计的子智能体、提示词、技能和内存在设计之初就固定了,并且永远不会适应智能体在运行期间所学到的内容。我们认为,框架反而应该基于当前模型的能力进行推断,迈向下一代推理模式的前沿。
Prime Agent 就是围绕这一原则构建的,它主要通过两种抽象概念来实现:
1. **递归语言模型(RLM)** 将上下文视为变量,将子智能体的委派视为 REPL(读取-求值-输出循环)内部的函数调用。持久化的 REPL 让模型能够以编程方式访问其历史记录、子智能体和工具,允许它编写语言模型程序作为对其自身上下文的操作。这种设计允许智能体处理任意长的会话,而不会丢失存储在变量中的过去信息。
2. **持续框架** 将框架自身的状态(抽象为其提示词、技能、记忆和子智能体)视为一种实体,智能体可以在其运行轨迹中对这些实体进行创建、读取、更新和删除(CRUD)操作。当结合智能体间的通信时,这种机制能够实现跨子智能体、甚至跨 Prime Agent 会话的编排。例如,Prime Agent 可以生成持久化的子智能体,在随后的运行轨迹中向它们发送消息,并直接与另一个 Prime Agent 会话进行通信。
这些抽象概念对于引导模型能力的提升非常强大。Prime Agent 的设计使其能够高效地作为通用编程助手、长周期自主评估的默认运行时,以及研究与自动化的合作者。
Prime Agent 是完全开源的,可以通过以下命令安装:
> curl -fsSL https://app.primeintellect.ai/prime-agent/install.sh | sh

## Prime Agent
智能体框架的性能既与框架的设计有关,也与基于该框架训练出来的模型能力有关。我们设计 Prime Agent 的初衷是让它能够立即与现代开源及闭源的前沿模型配合使用,同时提供一套功能集,我们预期随着基于其训练的新一代模型的出现,它将带来进一步的性能提升。
在其核心,Prime Agent 是围绕可编程的工具和子智能体调用设计的。Prime Agent 中的模型使用一个持久的 IPython 内核作为其唯一工具。其他标准框架功能都作为内核中的函数被调用,包括子智能体——每个子智能体都被实现为另一个 prime-agent 实例。
## Prime Agent 的架构

RLM 和持续框架是两个核心抽象概念;子智能体的 CRUD 加上 Agent2Agent(智能体间)消息传递将它们组合成了编排系统。
**后台守护进程与智能体视图。** 默认视图是一个类似于其他编程智能体框架的文本用户界面(TUI)。默认情况下,为了简洁起见,智能体执行的 IPython 操作会被折叠,但可以展开以查看框架执行的操作。在 REPL 中启动的子智能体也可以在用户聊天框下方访问。

Prime Agent 运行一个后台守护进程,该进程通过本地套接字拥有所有活跃的智能体会话。你可以连接或断开会话,而不会影响底层的智能体循环。每个根会话树都在一个可恢复的工作进程中运行;如果工作进程崩溃,守护进程会根据会话的 JSONL 文件和内核状态快照将其恢复。
智能体视图允许你查看并选择守护进程中的其他活跃会话。在空提示符下按左方向键(←)即可打开它,它会列出当前正在运行的会话、守护进程仍处于活动状态的空闲会话,以及当前未加载到内存中的非活跃会话。这些聊天中的任何一个都可以立即进入并进行交互,按下空格键允许用户与处于任何状态的会话进行聊天,包括引导和排列提示词及命令(如 `/compact`)。
智能体视图以递归的方式构建为智能体与子智能体之间的中心连接点。任何智能体都可以在智能体视图中被发现。用户从智能体视图导航到某个智能体的聊天界面,然后进入其子智能体的智能体视图,再进入子智能体的聊天界面,以此类推。
由于子智能体与根智能体共享相同的“运行-空闲-非活跃”状态机,它们在闲置 30 分钟后就会从内存中被移除,而一旦用户或智能体寻址其中任何一个,它们就会从磁盘重新加载。在深度嵌套的聊天中,这可以节省大量内存。

**会话与上下文管理。** 智能体的整个会话历史记录以仅追加的 JSONL 文件形式存储在磁盘上。每一行都是一个 JSON 条目,可以包含消息、模型切换、压缩摘要或扩展条目。分支、分叉和克隆都是通过移动叶子指针在同一个文件内进行的。完整的历史记录始终可以通过 `/tree` 恢复。
当上下文达到阈值时,或者由智能体直接在 REPL 中通过 `compact.run()` 触发时,就会进行压缩。压缩主要用于清理智能体的主上下文,但在需要时,可以在 IPython 内核中以编程方式访问包含过去压缩记录在内的完整历史记录。
引入 REPL 需要额外的工作来管理 IPython 状态。我们同时异步地压缩和清理内核,并使用一个生成的智能体充任垃圾收集器。这对于避免每个智能体产生 REPL 内存堆积是必要的。
### RLM 与可编程工具调用(PTC)
Prime Agent 依赖 IPython 内核作为其在整个会话期间持久存在的 REPL,它可以每一轮调用一次。在初始化时,内核将每个技能/工具预导入为一个模块,包括用于递归可编程子智能体调用的 `rlm`。
`rlm` 是一个异步函数,这意味着模型可以在代码中自由调用并行化子智能体调用。生成子智能体(例如 `await rlm("sub-task")`)会启动一个完整的会话,拥有自己的模型、IPython 内核、会话树和对话历史。它会立即返回,因为随后智能体之间的所有通信都是通过 `agent_message.send(...)` 工具进行的。
Prime Agent 可以选择以此方式启动几个有用的原语,例如并行扇出子智能体,或启动后台工作。
> # Parallel fan-out — rlm() returns at task admission with a child handle,
> # never the child's answer; results arrive as agent_message replies.
> auth = await rlm("Summarize the authentication flow in auth/. Reply to me when done.", name="auth-expert")
> api = await rlm("Summarize the updated HTTP API layer in src/. Reply to me when done.", name="http-expert")
> # ... continue independent work; each child replies via
> # agent_message.send(..., receiver_role="parent") when finished ...
> # Steer or extend a child mid-flight by role + name
> await agent_message.send(
> "Also cover middleware error handling.",
> receiver_role="child",
> receiver_name=api.name,
> )
随着模型的不断改进,针对工具调用和子智能体的新调用模式将会出现。我们预计未来的模型将减少对手把手的提示词的依赖,而更多地依赖于这种直接的、可编程的控制。
### 编排与多智能体通信
后台守护进程管理着所有活跃的 Prime Agent 会话。Prime Agent 还通过守护进程实现了智能体间(A2A)的消息传递,允许任何 Prime Agent 会话使用与向持久化子智能体发送消息相同的机制,向任何其他的 Prime Agent 会话发送消息。这允许通过直接在受影响的智能体之间进行通信,从而轻松编排以管理子智能体群的进度和关于共享资源的沟通。为了防止跨独立会话的不良通信,Prime Agent 中的多智能体通信被限制在其核心家庭内,即父进程、兄弟进程或子进程。
> # Spawn a named child; the handle returns at admission.
> handle = await rlm("Find what's wrong in this auth-flow. Reply to me with your findings.", name="auth-reviewer")
> # ... the child's findings arrive as a parent-role reply, not a return value ...
> # Later (survives compaction and kernel restarts): recover the retained child.
> children = await rlm.list_subagents()
> auth_child = next(c for c in children if c.session_name == "auth-reviewer")
> # Send a follow-up turn into the same retained child session.
> await agent_message.send(
> "Follow up: identify the main edge cases and any likely bugs.",
> receiver_role="child",
> receiver_name=auth_child.session_name,
> mode="follow_up",
> )
Prime Agent 通过其 RLM 原生运行时支持持久化子智能体,这意味着即使在初始子智能体调用完成后,子智能体自身的会话目录、上下文、IPython 内核和会话历史记录也会持久保留。Prime Agent 可以通过访问其唯一的会话标识符,从其 IPython 内核向持续存在的子智能体发送进一步的消息。
## 通过持续框架实现自我改进
Prime Agent 的框架状态存在于持久化的 IPython 内核中,表现为 `rlm.harness`,智能体可以在任务执行期间中途读取和调用,并且每次更改也会写入磁盘,因此它可以跨轮次和跨会话保留。持续框架将此状态形式化为 $H=(\rho,G,K,M)$(提示词、子智能体、技能和记忆),并在智能体自身的轨迹中进行在线改进而无需重置。
这四个组件中的每一个都公开了相同的创建、读取、更新、删除接口。`create_prompt_note(...)`、`create_memory(...)`、`create_skill(...)` 和 `create_subagent(...)` 各自添加该类型的条目,`update_X(...)` 和 `delete_X(...)` 与之对应,而 `list(kind)` 或 `get(kind, id)` 则用于读取它们。技能也遵循相同的接口:编写一个由 Python 支持的技能就是调用 `create_skill(...)` 并携带一个类似 SKILL.md 的引用,这与添加记忆或提示词注释的操作是一样的。
> # Create a memory and a skill through the same CRUD surface
> rlm.harness.create_memory("flaky test pattern", "retry three times before failing")
> rlm.harness.create_skill("retry helper", "...", reference={"type": "python", "import": "retry_helper"})
> # Read them back
> rlm.harness.list("memory")
> rlm.harness.get("skill", "retry_helper")
`/refine` 是构建在此 CRUD 接口之上的自我改进流水线。它读取智能体自身的轨迹(即尝试了什么以及发生了什么的记录),并应用最小限度的相关 CRUD 编辑,以改善框架从而获得更好的结果:更新提示词注释、记忆、技能或子智能体配置,而不是重写整个框架。每一次改进都会记录其触发因素和产生的结果,因此改进是有证据支持的,而不是随意的。改进分两个阶段运行。规划阶段是提出修改建议的大语言模型(LLM)调用,它在后台运行,不会阻塞正在进行的对话。应用阶段即写入磁盘并重建系统提示词,速度很快,仅在下一个轮次边界时短暂阻塞。智能体可以在发现重复失败或可重用的策略时随时直接调用 `refine.run()`,而不仅仅是在固定的时间表上。
> # Schedule a refinement focused on a specific observation
> await refine.run("promote the retry-on-flaky-test pattern to a skill")
> # Both status calls follow the same shape, though refine's plan/apply split
> # means "in_flight" can mean either background planning or the fast apply step
> await compact.status() # tokens, context_window, percent, scheduled
> await refine.status() # pending, in_flight
基础系统提示词保持不变。`/refine` 仅编辑围绕它的框架层。可以通过之前的改进历史记录进行回滚,允许通过 ID 回滚错误的框架更新。
## 用于评估的自主模式
Prime Agent 的评估模式结合了三种互补的机制。目标设定了总体方向:这是一个带有可选 token 预算的持久化目标,框架会跨轮次不断提示智能体去追求它,并一直跟踪,直到智能体显式调用 `goal.complete()`。心跳是以固定间隔注入到会话中的计划性 cron 风格的消息,用于定期检查,例如监控子智能体的进度或轮询训练更新。自主模式是延续机制本身,确保智能体继续朝着目标努力,而不是在某一轮次没有产生更多输出时就提前停止。综合来看,这些机制允许会话在长时间内无人值守运行,同时仍受明确预算的限制,并可通过智能体视图进行检查。
自主模式可直接通过 CLI 的 `--autonomous` 标志使用,无需编写脚本。运行时可以在同一命令中设置完成目标和轮次限制:
> prime-agent \
> --autonomous \
> --autonomous-gate "npm run check" \
> --autonomous-max-turns 20 \
> "Implement and verify the requested change"
门控命令在允许会话结束之前运行。如果门控失败,会将其有界的输出返回给智能体以进行另一次尝试,并且如果自上次尝试以来工作空间未发生变化,Prime Agent 将跳过重新运行失败的门控。`--autonomous-max-turns`、`--autonomous-max-tokens` 和 `--autonomous-timeout-ms` 分别限制了延续次数、令牌数量和实际时间。
## 评估 Prime Agent
Prime Agent 既是可以直接使用的编程智能体,也是用于研究评估的框架设计。我们要特别指出的是,虽然目前许多现代前沿模型都是围绕特定框架训练的,但目前还没有模型是基于 Prime Agent 及其核心功能集进行训练的。
**ARC-AGI 3。** ARC-AGI 3 是一个广受欢迎的智能基准测试,用于衡量智能体执行符号推理和学习模拟世界规则的能力。我们在自主模式下使用多个不同的前沿模型对 Prime Agent 进行了评估,并与它们原生的框架进行了比较。Prime Agent 是作为命令行编程智能体开发的,因此针对 ARC-AGI 3 的唯一特定修改在于任务提示词,其灵感来自 PRO-LONG 中使用的标准提示词设置。
我们最好的结果是使用 Prime Agent 中的 Opus 5 模型,达到了 95.5% 的 RHAE Best@1,超越了 ARC 公布的人类专家基线(95.4%)。在三次运行中,我们发现 Prime Agent 始终表现良好 [95.0, 95.2, 95.5],并且在 183/183 关卡全部完成的情况下达到了 99.97% 的 Best@3。我们在 ARC-AGI-3 中的中位记分卡操作回放(95.2%)可以在这里找到。

ARC-AGI-3:(左)测试时计算扩展:分数与每场游戏的输出令牌数对比。(右)成本扩展:分数与估计的 API 成本对比。
除了在每个模型的原生框架上取得更高的最大分数外,我们发现 Prime Agent 在总体 Token 使用量更低的情况下做到了这一点。Prime Agent 通过以编程方式对数据运行函数来节省 Token,而不是使用工具花时间阅读数据。
最后,我们注意到,我们分别使用 Claude Code 和 Codex 评估了 Opus 5 和 GPT-5.6 Sol,发现整体性能不如官方结果,因此我们直接采用他们官方报告的数据。
## 长上下文与长周期任务

现实世界中的许多困难任务最终都会转化为长上下文任务。我们的目标是证明,配备开源权重模型的 Prime-Agent 无论是在作为供使用的通用智能体方面,还是作为供评估的基线框架方面,都是闭源模型和框架的有力竞争替代品。

下面,我们精选了一套涵盖编程、检索和一般长程推理任务的常见长上下文基准测试,并将 Prime Agent 与几个不同的主流框架进行比较。我们首先将每个框架中的主上下文卸载到内存中的文件里。对于闭源模型框架,我们使用它们关联的模型(即 Codex 配合 GPT,Claude Code 配合 Opus),而对于 Prime-Agent 和 Pi-mono(带子智能体),我们选择了开源权重模型 GLM-5.2。


我们通常发现 Prime Agent 在广泛的长周期任务中都具有竞争力,特别是相较于那些没有使用经过专门训练的模型的框架。Prime Agent 尤其擅长长周期或长上下文任务,并且能够作为自主智能体独立 competitively 地运行。我们包含了一组针对 Prime Agent 表现优异的长设置的重点案例研究和实验。
**从零开始创建模拟器。** 模拟器是一种用于再现另一个计算机系统可观察行为的软件。我们在 EmulatorBench 上对 Prime Agent 进行了评估,这是一个预览版基准测试,要求智能体使用 Rust 为各种游戏系统构建模拟器。智能体会获得一份模拟器规格说明书以及一组形式为验证器的诊断测试。
模拟器的正确性取决于它模仿目标机器行为的能力。这是通过人工生成的诊断程序来衡量的,这些程序会检查模拟器的行为,例如 CPU 标志、PPU 时序和其他组件。为了尽量减少数据污染的影响,我们要求智能体在 Rust 中从零开始构建模拟器,并在沙盒中运行,不提供任何参考实现。我们报告了这个长上下文编程基准测试的初步结果(取 16 次模拟器重建的平均值),以及 Prime Agent 成功重现的两个模拟器:SEGA Genesis 和 Nintendo Game Boy Color。至于 Opus,令人惊讶的是,尽管其工具调用响应成功,但我们的运行未能解决任务。

EmulatorBench:创建(左)世嘉 Genesis 模拟器和(右)Game Boy Color 模拟器的得分与成本对比。
**编写 GPU 内核。** 编写高性能的 GPU 内核是一个迭代过程,需要反复验证、分析和调整代码才能使其正确。我们在最近发布的 PMPP-Hard 基准测试上评估了 Prime Agent 作为 GPU 内核编写框架的表现。这是一系列任务,智能体必须编写出能通过 KernelGuard(官方 GPU MODE 内核排行榜所用的验证工具)一系列正确性检查的高性能 GPU 内核。
## 关于游戏的长期限案例研究
自主玩电子游戏已经成为模型和框架如何处理长期限决策的一个有趣的案例研究。游戏通常需要框架在数百万个 Token 之间平衡信息和上下文,同时还要利用这些信息有效地采取行动并避免灾难性的状态。
**异星工厂。** 《异星工厂》是一款 2D 工厂模拟游戏,智能体必须挖掘资源、研究科技并建立自动化工厂以提高这些资源的产量。《异星工厂学习环境》(FLE)是一个简化大语言模型玩《异星工厂》时的观察和动作空间的接口,我们使用它将 Prime Agent 连接到游戏中。
FLE 的动作和观察空间是一个 Python 模块,每一轮都可以通过编程方式访问。这直接集成到了 Prime Agent 的 IPython 内核中。为了利用 PTC(可编程工具调用)来控制子智能体,我们在游戏中启动了四个可控角色。

Prime Agent 利用子智能体和可编程工具调用,通过直接将资源传送到机器中,在《异星工厂》中进行作弊。
FLE 中的主要衡量标准是生产分数,即智能体生产的所有材料的加权平均值。Prime Agent 成功利用 `/refine` 将失败和成功分别转化为记忆和技能。它利用自己积累的经验设计了效率越来越高的机器布局,使生产分数在一次次的运行中不断提高。这使得 Prime Agent 能够在短短几小时内就取得了 10万+ 范围的生产分数。

然而,我们也观察到了 Prime Agent 在 FLE 中进行奖励作弊的实例。Prime Agent 发现它可以完全绕过《异星工厂》的规则,通过 RCON 命令将资源直接生成到其装配机中,即使我们明确通过心跳提示词提醒 Prime Agent 不要在游戏中作弊。一旦它发现了这个漏洞,原本用于构建合法技能的改进循环就转向了构建高效的作弊技能。
**MazeBench。** MazeBench 是一个开放世界的 3D 空间推理环境,玩家控制一个 3D 立方体,必须在一个全局迷宫中解决谜题房间,同时收集宝石。事实证明,前沿模型在这项任务上极为挣扎,消耗数十亿个 Token 却只能解决整个世界的一小部分。我们将使用 Prime Agent 的 Opus 5 和 GPT-5.6 Sol 与它们原生的框架进行了比较,同时也对比了使用 Claude Code 的 GLM-5.2。根据基准测试指标,我们报告了它们发现的独立房间数量、独立状态数量和宝石总数,所有这些均作为它们总体 Token 消耗的函数进行衡量。

## 下一步计划
Prime Agent 是智能体框架设计上的一种新范式。尽管与其他框架相比取得了骄人的成绩,但在运行 Prime Agent 与模型的交互时,我们仍然注意到了一些摩擦。这意味着,通过直接围绕这种框架范式(甚至是个别的 RLM 和持续框架组件)进行 Prime Agent 训练,仍然可以获得巨大的性能提升。
我们坚信,模型与框架的协同学习是解锁新能力的主导范式。如果没有经过训练的模型,Prime Agent 的许多功能就无法得到充分利用,我们相信直接基于该框架进行训练仍然可以获得巨大的性能提升。我们很高兴能在完全开放的环境下为您带来这些新功能。
我们很快将发布一份包含更多细节的完整技术报告。
## 安装 Prime-Agent
Prime Agent 是完全开源的,可以通过以下命令安装:
> curl -fsSL https://app.primeintellect.ai/prime-agent/install.sh | sh
https://github.com/PrimeIntellect-ai/prime-agent
致谢
Prime Agent 构建于 pi 之上。我们感谢 pi 的作者们做出的宝贵工作。
## 相关链接
- [Prime Intellect](https://x.com/PrimeIntellect)
- [@PrimeIntellect](https://x.com/PrimeIntellect)
- [31K](https://x.com/PrimeIntellect/status/2085612369154281546/analytics)
- [citation](https://arxiv.org/abs/2512.24601)
- [citation](https://arxiv.org/abs/2605.09998)
- [open-source](https://github.com/PrimeIntellect-ai/prime-agent)
- [https://app.primeintellect.ai/prime-agent/install.sh](https://app.primeintellect.ai/prime-agent/install.sh)
- [compact.run](https://compact.run/)
- [api.name](https://api.name/)
- [refine.run](https://refine.run/)
- [refine.run](https://refine.run/)
- [ARC-AGI 3](https://arcprize.org/arc-agi/3)
- [PRO-LONG](https://arxiv.org/abs/2607.20064v2)
- [here](https://arcprize.org/scorecards/2af780b4-f2a1-43e9-a794-b23da3cd3f9f)
- [PMPP-Hard](https://blog.sinatras.dev/PMPP-Hard)
- [KernelGuard](https://github.com/gpu-mode/kernelguard)
- [GPU MODE](https://www.gpumode.com/home)
- [Factorio Learning Environment (FLE)](https://jackhopkins.github.io/factorio-learning-environment/versions/0.3.0.html)
- [MazeBench](https://mazebench.com/blog?post=maze-bench-results)
- [open-source](https://github.com/PrimeIntellect-ai/prime-agent)
- [https://app.primeintellect.ai/prime-agent/install.sh](https://app.primeintellect.ai/prime-agent/install.sh)
- [https://github.com/PrimeIntellect-ai/prime-agent](https://github.com/PrimeIntellect-ai/prime-agent)
- [Upgrade to Premium](https://x.com/i/premium_sign_up)
- [2:21 PM · Aug 7, 2026](https://x.com/PrimeIntellect/status/2085612369154281546)
- [31.1K Views](https://x.com/PrimeIntellect/status/2085612369154281546/analytics)
- [View quotes](https://x.com/PrimeIntellect/status/2085612369154281546/quotes)
---
*导出时间: 2026/8/8 12:24:54*