痛点
当前 agent 开发中,会涉及大量日志检索,每个日志就要几十MB,只要触发压缩,一些重要信息就模糊,长对话中很容易出现断片的情况
搜寻了下解决方案,当前这个 paper 不失为一种可行方案
论文摘要
PRO-LONG:程序式记忆赋能长程推理
sustained səˈsteɪnd
adj. 持续的,持久的;坚定的,坚持不懈的
v. 维持,保持;遭受,经受;(在体力或精神方面)支持,支撑
continual kənˈtɪnjuəl adj. 多次重复的,频繁的;持续的,不间断的
consequential ˌkɒnsɪˈkwenʃ(ə)l adj. 随之而来的,作为结果的;<法律>间接发生的,间接引起的;重要的,意义重大的
viable ˈvaɪəb(ə)l adj. 可望成功的,切实可行的;能存活的,能生长发育的
exploratory ɪkˈsplɒrət(ə)ri adj. 探索的,探查的,探究的;勘探的,考察的(常作定语)
Long-horizon tasks require sustained perception, reasoning, and exploration, and are a persistent challenge for large language model (LLM) agents. This gap is reflected in their limited performance on continual learning benchmarks such as ARC-AGI-3 and NetHack, especially when evaluated within specialized harnesses. Various agent harnesses have been proposed to close the gap, and each commits to a strategy for handling long sequences of observations, i.e., what information to save from the environment and how to load it into model context, a choice we argue is particularly consequential. Existing methods for context management have typically been designed around a tradeoff, where preserving more information makes relevant details harder to retrieve. Recent progress in coding agents, however, makes new approaches to memory viable. We propose PRO-LONG, a minimal context management framework built around programmatic memory for LLM agents in long-horizon, exploratory settings.
长程任务需要持续的感知、推理与探索(perception, reasoning, and exploration)能力,对大语言模型(LLM)智能体而言一直是一项持久挑战。这一短板体现(is reflected in )在它们在 ARC-AGI-3、NetHack 等持续学习基准(continual learning benchmarks)上表现有限,在专用评测框架(specialized harnesses)中评估时尤为明显。学界已经提出多种智能体框架试图弥补这一差距,每种框架都会选定一套策略来处理长序列观测数据(long sequences of observations):决定从环境中保留哪些信息、以及如何将信息加载进模型上下文,我们认为这个选择至关重要(particularly consequential)。现有的上下文管理方案通常围绕一组取舍关系设计:保存越多信息,后续检索关键细节就越困难(preserving more information makes relevant details harder to retrieve)。而代码智能体领域的最新进展,让全新的记忆方案成为可能。我们提出 PRO-LONG,这是一套极简上下文管理框架,面向探索类长程场景(long-horizon, exploratory settings)下的 LLM 智能体,核心是程序式记忆。
PRO-LONG addresses the tradeoff by keeping a complete, structured interaction log and using programmatic tools to search this history efficiently. On NetHack, we find increasing gains from using PRO-LONG for cross-episodic memory, with scores reaching up to 2.2× those of a base coding agent. On the full ARC-AGI-3 public game set, PRO-LONG improves over this baseline agent by an average of 18.0 percentage points across frontier models, and matches or exceeds state-of-the-art specialized harnesses (up to 97.4% best@2) while using 4.2--5.8× fewer tokens. Relevant code and logs are available at https://github.com/alexisfox7/PRO-LONG.
PRO-LONG 通过保留一份完整、结构化的交互日志,并使用程序化工具高效检索这段历史记录,来解决上述取舍矛盾。在 NetHack 上,使用 PRO-LONG 实现跨回合记忆(cross-episodic memory)可以持续带来性能提升,最高得分可达基础代码智能体的 2.2 倍。在完整 ARC-AGI-3 公开游戏数据集上,在多款前沿模型上,PRO-LONG 相比基线智能体平均提升 18.0 个百分点;它可以追平甚至超越专门框架的 SOTA 结果(best@2 最高 97.4%),同时 token 消耗减少至原来的 1/4.2 ~ 1/5.8。相关代码与日志见:https://github.com/alexisfox7/PRO-LONG
Introduction
Large language model (LLM) agents are being increasingly deployed on more challenging, longer-horizon tasks. Continual learning benchmarks such as ARC-AGI-3 ARC Prize Foundation, 2026 and NetHack Küttler et al., 2020 have subsequently been proposed to evaluate agent progress, testing whether these agents can infer unknown environment dynamics through exploration and continuously improve over thousands of actions. Out-of-the-box frontier LLMs, evaluated without harnesses or tool access, perform poorly on these settings, achieving limited progression on both ARC-AGI-3 and NetHack ARC Prize Foundation, 2026, Paglieri et al., 2025.
大语言模型(LLM)智能体正越来越多地被部署到难度更高、周期更长的任务中。ARC-AGI-3 ARC Prize Foundation, 2026、NetHack Küttler 等人,2020 这类持续学习基准随之被提出,用于评估智能体能力:测试智能体能否通过探索推断未知的环境规律,并在成千上万次动作交互中持续进步。不带框架、无工具能力的原生前沿大模型,在这类场景表现很差,在 ARC-AGI-3 和 NetHack 上进展有限 ARC Prize Foundation, 2026, Paglieri 等人,2025。
externalize ɪkˈstɜːnəlaɪz vt. 给......以外形,使具体化,使客观化;<正式>表露(思想、情感等)
spirit ˈspɪrɪt
n. 精神,心灵;情绪,心境;勇气,意志,活力;(对团体、队伍、社会的)忠心,(群体中的)态度,精神;心态,态度;本质,精髓,基本精神;真实意义,实质;灵魂,鬼魂;具有特别品质的人物,在群体或活动中发挥特殊作用的人物;烈酒;挥发性液体(尤指用蒸馏法提炼的燃料);神灵;圣灵(Spirit,Holy Spirit 的简称)
v. 偷偷带走,秘密弄走;鼓励,鼓舞
scaffold ˈskæfəʊld
n. 脚手架,鹰架;(旧时的)绞刑台,断头台;(生物医学)支架,细胞支架
vt. 给......搭脚手架;用支架支撑
considerable kənˈsɪdərəb(ə)l adj. 相当大的,相当重要的;(人)显要的,值得尊敬的
To close this gap, a range of agent harnesses for exploratory tasks, wrapping a base model with memory, tools, and other scaffolding, have shown considerable promise. In parallel, and of particular relevance, agents with access to programmatic tools, such as Claude Code and Codex, have advanced rapidly. Programmatic access enables forms of memory and reasoning that were previously impractical, such as structured search over very large logs. Recent work externalizes long-context processing in a similar spirit, for example through recursive language models that query slices of context through a REPL Zhang et al., 2025a. These trends point toward a broader role for coding agents as context processing systems.
为弥补这一短板,一系列面向探索任务的智能体框架涌现出来:给基础模型搭配记忆、工具以及其他辅助组件,已经展现出巨大潜力(considerable promise)。与此同时,一类和本工作高度相关的方向快速发展:可调用程序化工具的智能体(例如 Claude Code、Codex)。程序化访问实现了过去难以落地的记忆与推理方式,比如在海量日志上做结构化检索(Programmatic access enables forms of memory and reasoning that were previously impractical, such as structured search over very large logs)。近期一些工作也以相似思路把长上下文处理外置,例如递归语言模型,通过 REPL(Read-Eval-Print Loop,读取 - 求值 - 打印循环) 读取分片上下文 Zhang 等人,2025a。这些趋势说明,代码智能体可以承担更广泛的角色(point toward a broader role,指向更广泛的角色):作为上下文处理系统。
Read:读取输入的代码
Eval:解释 / 求值这段代码
Print:把执行结果打印出来
Loop:回到第一步,等待下一次输入
coherence kəʊˈhɪərəns n. 连贯性,条理性;凝聚,凝聚力
rot rɒt
v.(使)腐败,(使)腐烂;逐渐衰弱(或憔悴);<英,旧,非正式>取笑,开玩笑
n. 腐烂,腐烂物;<英>腐化,堕落(the rot);<美>官员腐败
For these agents to maintain long-horizon competence and coherence, how to properly engineer context becomes a central concern. A natural way to frame agent context management is to distinguish between the accessed information, through the active context window of the Transformer network, and the accessible information, namely memory (i.e., retrievable states such as a log file, saved notes, or an embedding store). Although modern LLMs can process context windows of a million tokens or more, performance remains expensive and vulnerable to degradation as trajectories grow, a phenomenon often referred to as context rot Hong et al., 2025. Agents therefore require mechanisms that decide what history remains accessible and how relevant pieces are moved into context.
如果想要这类智能体在长程任务中保持能力与逻辑自洽(coherence),如何合理设计上下文就成为核心问题。一种很直观的上下文管理思路,是区分两类信息:一类是已访问信息,也就是 Transformer 当前活跃上下文窗口内的内容;另一类是可访问信息,也就是记忆(即可检索状态,例如日志文件、保存的笔记、向量存储库)。尽管现代 LLM 可以处理百万 token 及以上的上下文窗口,随着交互轨迹不断变长,推理成本依旧很高,性能也容易下滑(vulnerable to degradation),这个现象常被称为上下文衰减(context rot)Hong 等人,2025。因此智能体需要一套机制,决定哪些历史记录长期可检索、以及如何把相关片段载入上下文。
PRO-LONG 框架
versus ˈvɜːsəs prep. (比赛或诉讼中)以......为对手,与......竞争;与......相对,与......相比
Overview of programmatic memory (PRO-LONG) integrated into a basic coding agent setup. The agent has access to a tool space of increasingly programmatic capabilities (read, grep, bash/python), and full, structured logs of environment state are written to log.txt.
Note the accessed context (limited to ∼100K--1M tokens) versus the far larger accessible context (10M+ tokens).
Two example ARC-AGI-3 games are shown on the right: g50t, which requires controlling a "ghost clone," and tu93, a maze game.
这是集成在基础代码智能体架构中的程序化内存(PRO-LONG)概览。
该智能体可调用一组程序化能力逐步增强的工具集(读取、grep 检索、bash/python 脚本执行),环境状态的完整结构化日志会写入 log.txt 文件
请注意区分已访问上下文(上限约 10 万~100 万 token)和规模大得多的可访问上下文(1000 万 token 以上)
右侧展示了两个 ARC-AGI-3 任务样例:g50t,需要操控一个 "幽灵克隆体";tu93,是迷宫游戏

accessible context = 仓库里全部的存量资料(能拿到,但不直接喂给模型)
accessed context = 这次推理,真正塞进 LLM 上下文窗口、给模型看到的内容
heuristics hjuˈrɪstɪks n. 启发法,试探法,启发式方法;(心理学)认知启发式,判断与决策中的心理捷径
scratchpad ˈskrætʃpæd n. 便条簿,草稿本,便笺簿;(计算机)暂存存储器,暂时存储器
analogous əˈnæləɡəs adj. 相似的,类似的;(器官)同功的
fidelity fɪˈdeləti n. (对配偶或伴侣的)忠贞;(对人、组织或信仰的)忠诚;精确性
tractability ˌtræktəˈbɪləti n. 温顺,驯良,顺从;易处理性,可控性,可处理性;(数学、计算复杂性理论)可解性
PRO-LONG 的思路:把海量历史存在外面(accessible),模型需要时,靠代码 / 工具(grep、read)按需检索、提取一小部分,只把有用的片段加载进 prompt(accessed)
Proposed agent memory systems can be understood as various implementations of READ and WRITE operations over externally stored information Zhang et al., 2025b.
现有各类智能体记忆系统,都可以理解成对外部存储信息做「读(READ)、写(WRITE)」的不同实现方案
WRITE is defined by heuristics for what information should be accessible or persisted, whether agent-authored, human-designed, learned, or task-specific. Examples include scratchpad notes, summarized observations, embedded memory entries, and distilled skills or strategies Park et al., 2023, Packer et al., 2023, Chhikara et al., 2025, Ouyang et al., 2026, Xia et al., 2026.
WRITE(写):依靠人工启发式规则,决定哪些信息需要保留、持久化;不管内容是智能体自己生成、人写的、模型学到的,还是任务专属信息。例子包括草稿笔记(scratchpad)、摘要化的观测记录、向量记忆条目、提炼出来的技能 / 策略。
READ then determines what is ultimately accessed in context through analogous operations, such as embedding-based retrieval, loading selected memory chunks, keyword search over stored files, or restoring earlier context snapshots Lewis et al., 2020, Wu et al., 2025.
READ(读):决定最终哪些内容会被加载进上下文。手段常见:向量检索、取出选定记忆块、文件关键词检索、恢复历史上下文快照
This creates a fidelity--tractability tradeoff. Reducing what is saved at WRITE time makes READ easier, but can discard details whose relevance is evident only in hindsight. Over long horizons, the cost of these decisions accumulates, as a lossy summary can matter many turns later.
这里存在一个 保真度(fidelity)--- 可处理性(tractability)权衡(fidelity--tractability tradeoff):
写的时候主动精简、丢掉一部分信息,后续读的时候检索会更轻松;但会丢掉一些事后才发现很关键的细节。在超长任务轨迹下,这种损失会不断累积 ------ 一份有损(lossy)压缩摘要,很可能在几十轮之后才发现缺了关键信息。
timeliness ˈtaɪmlinəs n. 及时性,时效性,适时性
capitalize ˈkæpɪtəlaɪz 用大写字母书写(或印刷),把......首字母大写;为(开办或发展企业)提供资金;(将资产或股票)变现,使资本化;(根据公司的股票价值或其收益)核定(公司的)资本;利用(capitalize on)
are capitalizing on 充分利用
elicit ɪˈlɪsɪt v. 引出,得到;<古>使(潜在的东西)显现,诱出
emphasize ˈemfəsaɪz v. 强调,着重;重读(单词或短语);使突出
A timeliness question is also raised as to whether these systems are fully capitalizing on, or are maximally compatible with, modern coding agent capabilities.
同时还有时效性问题:这些记忆方案,有没有充分利用(are fully capitalizing on)、适配当下代码智能体的能力?
We propose PRO-LONG, a context management framework for eliciting programmatic, long-horizon reasoning.
本文提出 PRO-LONG:一套上下文管理框架,用来实现程序化、长时序推理。
PRO-LONG centers on our notion of programmatic memory for agents, which we define the WRITE operation as the harness appending every observation, action, and outcome into a log, and the READ as programmatic search over that log, primarily through code.
PRO-LONG 的核心是程序化记忆(programmatic memory):
WRITE:把每一条观测、动作、返回结果全部原样写入日志;不做摘要、不筛选
READ:用代码去检索这份日志(grep、正则、python 脚本等程序化方式)
We emphasize three motivating design principles 它三条核心设计原则:
- Simplicity 简洁性
WRITE 阶段不需要启发式、不需要模型决策该存什么,环境输出啥就原样写入;READ 不需要专门的检索组件(不用向量库、索引) - Losslessness 无损
写入时不压缩、不摘要,日志是环境状态忠实、原始的真值记录 - 原生适配代码智能体
正则/脚本这类程序化搜索,本来就是 coding agent 天然会用的能力;哪怕日志极长,检索依然可控。论文实测:十几万行日志都可以稳定检索
regress rɪˈɡres
v. 倒退,回归;(尤指因催眠或精神疾患)回到从前;(统计)回归
n. 退回;(哲)倒溯论证

GREP: Find past actions
shell
grep -nH "Tool Call: ACTION6" logs.txt
作用:用 grep 在巨大日志里,定位之前所有 ACTION6 动作在哪一行
拿到:动作 + 行号,后续就可以去对应行附近,读出当时的棋盘状态
这一步就是 PROGRAMMATIC SEARCH,不是向量检索,就是原生 shell 文本检索
BASH: Test simulator against log
shell
python3 regress.py
智能体写了一个回归 regress 脚本 regress.py:
拿自己当前写的游戏模拟器,复现日志里记录的历史动作,对比模拟器输出 和 日志里真实记录的棋盘状态。
输出:48 ok, 15 bad
发现:有 15 个 case 对不上,说明它对游戏规则(rotate 旋转逻辑)的理解是错的。
BASH: Fix and check again
智能体修改模拟器代码(修正解析 / 旋转规则),反复跑回归:
- 第一次修复:
62 ok, 1 bad - 第二次修复:
63 ok, 0 bad
所有历史日志里的动作,现在模拟器都可以复现,bug 全部修好
Plan with the corrected simulator
智能体得出结论:现在模拟器和历史日志完全对齐,它搞懂了旋转规则
接下来用这个修好的模拟器,继续规划新动作