Hacker News ★ 98 4 min

Prime Agent: A self-improving RLM agent

🔗 https://www.primeintellect.ai/blog/prime-agent

📌 【Xeophon 開源專案】Prime Agent:透過 RLM 與持續性架構,實現自我改進的 AI Agent

TL;DR:Prime Agent 透過 RLM 與持續性架構,讓 Agent 能以程式化方式操作自身上下文與子代理。

目前的 AI Agent 架構設計往往受限於舊時代模型的技術瓶限:固定的工具呼叫(tool-calling)模式與上下文壓縮(context compaction)機制,迫使模型必須在既定的腳手架(scaffolding)中掙扎,而非真正利用這些工具。設計者通常在開發時就寫死了子代理、提示詞(prompt)與記憶體,這些設定無法隨著 Agent 在執行過程中的學習而動態調整。

Xeophon 提出的 Prime Agent 旨在打破這種靜態限制,透過兩大核心抽象概念,讓 Agent 能夠隨著能力的提升而演進。

🧩 核心架構:RLM 與持續性架構 (Continual Harness)

Prime Agent 的設計核心在於將 Agent 的行為從「被動接受指令」轉向「程式化控制」:

  • 遞迴語言模型 (Recursive Language Model, RLM):將上下文(context)視為變數,並將委派子代理(sub-agent delegation)視為 REPL(互動式解釋器)中的函式呼叫。這讓模型可以編寫「語言模型程式碼」來對自身的上下文進行操作,並透過持續性的 REPL 擁有對歷史紀錄、子代理與工具的程式化存取權,從而處理極長時程的對話而不會遺失資訊。
  • 持續性架構 (Continual Harness):將架構本身的狀態(包含提示詞、技能、記憶體與子代理)抽象化,讓 Agent 能夠透過 CRUD(增刪查改)操作來管理這些狀態。這使得 Agent 可以在執行過程中,根據自身學到的經驗來更新或建立新的技能與代理。

📊 透過 A2A 通訊實現多代理協作

結合上述機制,Prime Agent 實現了強大的代理間通訊(Agent-to-Agent, A2A):

  • 代理編排:Agent 可以啟動持久性的子代理,並在後續流程中再次傳送訊息給它們。
  • 跨會話溝通:不同 Prime Agent 會話之間可以直接進行通訊,實現複雜的任務編排。
  • 遞迴式視圖:透過背景守護進程(background daemon),使用者可以進入任何一個子代理的視圖,並在巢狀結構中不斷深入探索不同層級的代理。

🛠️ 實作細節:以 IPython 核心為中心

Prime Agent 的設計理念是讓模型能直接進行程式化工具呼叫(Programmatic Tool-Calling, PTC):

  • 唯一的工具是 IPython 核心:模型使用一個持續存在的 IPython kernel 作為其 REPL。其他的架構功能(如子代理、技能)都被實作為 kernel 中的函式。
  • 非同步子代理呼叫:透過 rlm() 函式,模型可以非同步地啟動子代理(例如使用 await rlm(...)),並在子代理完成任務後透過 agent_message.send() 接收回傳結果。這支援了並行處理(fan-out)任務,讓模型可以同時啟動多個專家代理進行獨立工作。
  • 記憶體與狀態管理
    • Session 紀錄:完整的對話歷史儲存在硬碟的 append-only JSONL 檔案中,支援分支、分叉與複製。
    • 自動壓縮:當上下文達到閾值時,會透過另一個專門擔任「垃圾回收(garbage collector)」角色的 Agent 來非同步地進行壓縮與清理,以避免 REPL 記憶體堆積。
    • 資源優化:閒置 30 分鐘的代理會從記憶體移除,僅保留在磁碟中,一旦被存取便會立即重新載入。

🎯 實務啟示

對於開發者而言,Prime Agent 提供了一種全新的思考範式:不再僅僅是撰寫 Prompt,而是將 Agent 視為一個可以透過程式碼操控自身狀態與工具的執行環境。這種設計對於開發需要長期運作、具備自我演進能力或需要複雜多代理協作的自主評估(autonomous evaluation)與研究任務具有高度價值。

🔗 來源

#AI #Agent #MachineLearning #OpenSource #RLM #Python #IPython #MultiAgent #SoftwareEngineering #AutonomousAgents

原始資料 Hacker News · 收集於 2026-08-06
來源原標題
Prime Agent: A self-improving RLM agent
作者
Xeophon
原始標籤
hackernews
來源訊號
HN points 174 HN 留言 32
原始連結
https://www.primeintellect.ai/blog/prime-agent

摘要原文

Prime Agent: A self-improving RLM agent 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: 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. 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. (174 points, 32 comments on Hacker News)

tencent/hy3:free 自動生成