PrimeIntellect-ai/prime-agent:可自我改进的 RLM Agent
英文标题:🔥 PrimeIntellect-ai/prime-agent
Prime Agent 是一个面向编程与研究任务的开源 Agent,基于持久化 Python 控制环境和可持续改进的 Harness 状态,支持通用及长时运行工作流。其核心 RLM 抽象将上下文视为变量,并通过递归子 Agent 进行程序化调用;Continual Harness 则持久化提示、记忆、技能描述和可复用的子 Agent 规范。该工具支持后台会话、Agent 间通信、自动压缩、心跳、定时任务、持久化目标和受限自治模式,适合研究评测与长期自动化任务。Prime Agent 可在 macOS 或 Linux 上安装,但执行模型生成的 Python 和项目命令时使用用户权限,因此不应被视为安全沙箱。
18.9 KB
20.2 KB
51.6 KB
中文
Prime Agent:可自我改进的 RLM Agent
文档 • Verifiers • PRIME-RL • pi-mono
Prime Agent 是一个面向通用及长时运行工作的开源编程与研究 Agent。它围绕两个核心抽象设计:
- 递归语言模型(Recursive Language Model,RLM) 将上下文视为变量(prompt-as-a-variable),并将递归子 Agent 等工具视为持久化 REPL 内的函数调用(programmatic tool /sub-agent calling)。
- Continual Harness 将补充提示、记忆、技能描述和可复用的子 Agent 规范保存为持久状态。默认情况下,这些状态局限于当前会话,Prime Agent 可以通过小幅、基于证据的更新对其进行改进。
Prime Agent 将持久化 Python 控制环境与持久化 Harness 状态结合起来,使有用的工作上下文和可复用的操作模式能够超越单个聊天窗口持续存在。
- 一切都以程序方式执行: 持久化 IPython 是内置的模型工具;文件操作、Shell 命令、工具调用、子 Agent 以及上下文管理都通过代码完成。
- 内置子 Agent:
rlm(...)可以生成真正的子 Agent,用于并行或后台工作,并以程序方式返回结果。 - Harness 可以持续改进:
/refine会检查当前轨迹,并可以对补充 Harness 状态应用小幅、基于证据的更新。它不会重写不可变的基础系统提示,记录的快照支持回滚。 - 技能可执行: 技能是可导入的 Python 包,内置技能创建器可以将重复性工作流转化为项目级或个人级技能。
- 会话在后台运行: 基于守护进程的 Agent 即使在终端断开后仍会继续运行,之后可以重新连接。
- Agent 直接通信: 运行中的 Agent 可以相互交换消息并进行编排,无需所有信息都经过用户转发。
- 长时任务持续推进: 自动压缩、持久化目标、心跳、定时任务、自治模式和保留的子 Agent 可以在多轮交互及终端会话之间保留进度。
在 macOS 或 Linux 上安装最新稳定版本:
bash curl -fsSL https://app.primeintellect.ai/prime-agent/install.sh | sh
安装程序会下载带版本号的发行版、验证其 SHA-256 校验和、安装 prime-agent 命令,并可以准备 Agent 使用的 IPython 运行时环境。
从希望 Prime Agent 操作的仓库或目录启动:
bash cd /path/to/project prime-agent
首次启动时,运行 /login 以选择订阅或 API 密钥提供商。Prime Agent 会在当前目录中工作,并可以在其中运行命令和修改文件。请使用可丢弃的克隆、干净的工作树或其他便于检查和恢复的检查点。
警告
Prime Agent 会以用户权限执行模型生成的 Python 代码和项目命令。其 Worker 和 Kernel 进程改善了生命周期隔离与恢复能力,但它们不是安全沙箱。请检查变更,并且仅使用受信任的仓库、指令、技能和扩展。在外部沙箱或受限环境中运行不受信任的代码或指令。
常用命令:
bash prime-agent agents # 浏览运行中、空闲和已保存的会话 prime-agent attach # 重新连接到运行中的会话 prime-agent --resume <path|id> # 恢复已保存的会话 prime-agent status # 检查后台服务状态 prime-agent doctor [--fix] # 检查或修复后台服务 prime-agent update [--force] # 更新 Prime Agent prime-agent shutdown [--force] # 停止所有 Agent、Worker 和后台服务
为长时运行工作而构建
Prime Agent 专为长时运行工作构建,尤其适用于研究中的评测任务。这些功能在 TUI 和自治运行模式下均可用。
-
Continual Harness:
/refine可以将经过审查、聚焦明确的经验持久化为补充提示、记忆、可复用的技能描述或子 Agent 规范,并记录改进历史。它不会替代对新可执行技能的打包与审查。 -
Agent 间直接通信: 运行中的 Agent 和保留的子 Agent 可以互相发现、交换消息并引导正在进行的工作。
-
基于守护进程的连续性: 活跃会话、IPython 状态、定时任务和子 Agent 会在终端分离后继续运行,之后可以重新连接。
-
心跳与定时任务:
/heartbeat、rlm_heartbeat和prime-agent schedule可以定期重新进入会话,或在指定时间重新进入会话。 -
持久化目标:
/goal会让目标及其进度在多轮交互中保持活跃,直到目标完成、暂停或被清除。 -
有界自治模式:
/autonomous会在配置的轮次、Token 和时间预算内继续运行,并可以执行用户定义的质量门。通过质量门只代表该质量门所验证的内容;达到限制并不意味着任务成功。 -
快速入门 — 安装、身份验证并运行第一个会话
-
使用指南与 CLI 参考 — 命令、会话、自治限制和输出模式
-
长时运行与后台 Agent — 分离与重新连接、目标、心跳和定时任务
-
RLM 编程模型 — 持久化 IPython、子 Agent、技能和信任模型
-
技能 — 安装并创建可复用能力
-
提供商设置 — 订阅和 API 密钥提供商
-
架构概览 — 守护进程、Worker、Kernel 和持久化边界
-
开发 — 从源代码构建和运行
我们的 Agent 和 TUI 构建在 pi 之上。感谢 pi 的作者所做的出色工作。
Prime Agent 完全开源,并依据 MIT License 发布。
English / 原文
Prime Agent: A Self-Improving RLM Agent
Documentation • Verifiers • PRIME-RL • pi-mono
Prime Agent is an open-source coding and research agent for general and long-running work. It is designed around two core abstractions:
- The Recursive Language Model (RLM) treats context as variables (prompt-as-a-variable) and tools like recursive subagents as function calls (programmatic tool /sub-agent calling) inside a persistent REPL.
- The Continual Harness stores supplemental prompts, memories, skill descriptions, and reusable subagent specifications as durable state that Prime Agent can refine through small, evidence-backed updates, local to the session by default.
Prime Agent combines a persistent Python control environment with durable harness state, so useful working context and reusable operating patterns can outlive a single chat window.
- Everything is programmatic: persistent IPython is the built-in model tool; file operations, shell commands, tool use, subagents, and context management happen through code.
- Subagents are built in:
rlm(...)spawns real child agents for parallel or background work and returns their results programmatically. - The harness can improve:
/refinereviews the current trajectory and can apply small, evidence-backed updates to supplemental harness state. It never rewrites the immutable base system prompt, and recorded snapshots support rollback. - Skills are executable: skills are importable Python packages, and the built-in skill creator can turn recurring workflows into project or personal skills.
- Sessions run in the background: daemon-backed agents keep running when the terminal disconnects and can be reattached later.
- Agents communicate directly: running agents can exchange messages and orchestrate one another without routing everything through the user.
- Long tasks keep moving: automatic compaction, persistent goals, heartbeats, schedules, autonomous mode, and retained subagents preserve progress across turns and terminal sessions.
Install the latest stable release on macOS or Linux:
curl -fsSL https://app.primeintellect.ai/prime-agent/install.sh | sh
The installer downloads a versioned release, verifies its SHA-256 checksum, installs the prime-agent command, and can prepare the IPython runtime used by the agent.
Start Prime Agent from the repository or directory you want it to work in:
cd /path/to/project
prime-agent
On first launch, run /login to choose a subscription or API-key provider. Prime Agent works in the current directory and can run commands and modify files there. Use a disposable clone, clean worktree, or another checkpoint you can inspect and restore.
Warning
Prime Agent executes model-generated Python and project commands with your user permissions. Its worker and kernel processes improve lifecycle isolation and recovery; they are not a security sandbox. Review changes and use trusted repositories, instructions, skills, and extensions only. Run untrusted code or instructions in an external sandbox or restricted environment.
Useful commands:
prime-agent agents # Browse running, idle, and saved sessions
prime-agent attach <agent> # Reattach to a running session
prime-agent --resume <path|id> # Resume a saved session
prime-agent status # Inspect background service state
prime-agent doctor [--fix] # Inspect or repair background services
prime-agent update [--force] # Update Prime Agent
prime-agent shutdown [--force] # Stop every agent, worker, and background service
Built for Long-Running Work
Prime Agent is built for long-running work, especially for evaluations in research. These features are available in the TUI, and when run autonomously.
-
Continual Harness:
/refinecan persist focused, reviewable lessons as supplemental prompts, memories, reusable skill descriptions, or subagent specifications, with recorded refinement history. It does not replace packaging and reviewing new executable skills. -
Direct agent-to-agent communication: running agents and retained subagents can discover one another, exchange messages, and steer active work.
-
Daemon-backed continuity: active sessions, IPython state, schedules, and subagents keep running when the terminal detaches and can be reattached later.
-
Heartbeats and schedules:
/heartbeat,rlm_heartbeat, andprime-agent schedulecan re-enter a session periodically or at a specific time. -
Persistent goals:
/goalkeeps an objective and its progress active across turns until it is completed, paused, or cleared. -
Bounded autonomous mode:
/autonomouscontinues within configured turn, token, and time budgets and can run user-defined quality gates. A passed gate checks only what that gate verifies; reaching a limit does not imply task success. -
Quickstart — install, authenticate, and run a first session
-
Usage and CLI reference — commands, sessions, autonomous limits, and output modes
-
Long-running and background agents — detach and reattach, goals, heartbeats, and schedules
-
RLM programming model — persistent IPython, subagents, skills, and the trust model
-
JSON mode and RPC mode — headless automation and integrations
-
Skills — install and create reusable capabilities
-
Provider setup — subscription and API-key providers
-
Architecture overview — daemon, worker, kernel, and persistence boundaries
-
Development — build and run from source
Our agent and TUI is built on top of pi. We thank the authors of pi for their valuable work.
Prime Agent is fully open source and released under the MIT License.