让记忆实时参与推理循环,大幅提升语言代理的记性与效率。
Memory in the Loop: In-Process Retrieval as Extended Working Memory for Language Agents

- 将记忆存取嵌入每一步推理中,实现动态实时更新与调用。
- 在本地存储下,每步延迟仅80-165微秒,召回率从0提升至3.6-4.8/5。
- 适合追求低延迟、高响应精度的语言智能体系统设计者。
语言代理以‘观察-推理-行动’为循环运行,但其记忆始终在循环外,每轮最多查询一次。本文研究将记忆移入循环内部,在每一步读写的新范式。此前障碍在于延迟:网络化存储需数十至数百毫秒响应,导致端到端延迟最高膨胀83倍。现有方法仅通过调度或限制查询频次来缓解,而非根本解决。我们指出,延迟本质是存储位置问题——本地存储响应仅约100微秒,比网络模式快三个数量级,此时每步开销可忽略。依据扩展心智论的对等原则,足够快速且持续可用的存储即成为延伸工作记忆。实验表明,在固定每轮延迟预算下,延迟越高,冗余操作越多:本地存储时0/12次冗余,110毫秒云往返时达7.2/12次(精确置换检验p=0.0079)。四款GPT-5级模型验证了该范式:在有限窗口内,召回率从0/5提升至3.6-4.8/5,存储操作中位数为80-165微秒;尽管指令重述基线也能完美解决,但代价随工作集增长。所有244次写入均成功保留,任何遗漏均由代理读取策略导致,非存储故障。测量还定位瓶颈:网络嵌入耗时200-400毫秒;结合小型本地嵌入器后,全程延迟降至约40微秒。
原文摘要 · Abstract (English)
Language agents run a loop - observe, reason, act - but the memory they reason over sits outside it: a store queried at most once per turn. We study the regime where memory moves inside the loop, read and written on every step. The obstacle has always been latency: networked stores answer in tens to hundreds of milliseconds, and in-loop retrieval can inflate end-to-end latency by up to 83x when retrieval is expensive. Prior work manages that cost rather than questioning it: serving-layer scheduling hides it, "memory-first" designs ration retrieval to once per turn. We argue latency is a property of where the store lives, not the in-loop pattern: an in-process store answers in ~100us, three orders of magnitude below the network regime, and at that speed the per-step tax collapses. By the extended-mind thesis's parity principle, a store fast enough to be constantly and directly available becomes extended working memory, not a tool the agent merely consults. The premise is causal: holding a fixed per-turn memory-latency budget and varying only the store's answer speed, redundant actions rise monotonically with latency - 0.0 of 12 at in-process speed, 7.2 of 12 at a 110ms cloud round trip (gpt-5-nano, gpt-5-mini; exact permutation p=0.0079). We demonstrate the regime end-to-end: across four GPT-5-class models under a bounded window, recall improves from 0/5 to 3.6-4.8/5 with in-loop memory, store ops at p50 80-165us - though an instructed restate-every-reply baseline also solves it perfectly, at a token cost that grows with the working set. The store never lost a fact in any run (244 of 244 writes kept); every miss traces to the agent's read policy, not the store. Our measurements also relocate the bottleneck: the dominant per-step cost is embedding (~200-400ms over the network); pairing the in-process store with a small local embedder returns the complete operation to a measured ~40us.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。