工程与开发者ReAct风格代理循环的记忆
为ReAct代理循环提供每个思想、行动和观察的记忆
ReAct(推理 + 行动)循环生成一个思想,采取一个行动,观察结果,然后重复。每次迭代通常会清除早期迭代所需的上下文。MemoryLake为ReAct代理在迭代、会话和运行之间提供持久记忆。
问题:ReAct迭代在思想步骤之间失去上下文
在长ReAct追踪的第20次迭代中,最初的目标被转述,早期观察被总结,代理正在基于其自身发现的第三代副本进行推理。ReAct在理论上强大,但在没有持久记忆的情况下在实践中会丢失信息。
MemoryLake如何支持ReAct循环
每次迭代提交记忆
每个思想/行动/观察三元组存储为类型化记忆。
跨迭代检索
后续步骤检索特定的先前思想或观察。
跨迭代锚定的目标记忆
固定的原始目标防止漂移。
跨运行的反思记忆
先前运行中的模式为当前规划提供信息。
免费开始使用
永久免费 · 无需信用卡
ReAct记忆的工作原理
- 连接 — 将MemoryLake接入ReAct循环的提交步骤。
- 结构 — 每个思想/行动/观察变为类型化记忆。
- 重用 — 后续迭代根据相关性检索特定的先前步骤。
前后对比:ReAct循环记忆
| Without MemoryLake | With MemoryLake | |
|---|---|---|
| Iteration 20 sees iteration 1's observation | Paraphrased | Retrieved verbatim |
| Cross-run learning | None | Reflection memory |
| Goal preservation | Drifts | Pinned |
| Audit reasoning chain | Limited logs | Memory provenance |
适合谁
在生产中运行ReAct风格代理的团队 — 研究代理、浏览代理、编码代理 — 在迭代次数增加时循环质量下降的场景。
可运行的 demo约 4 分钟
在你自己的账号上跑通这个场景
Tarnwick 的排障 agent 用 ReAct 循环处理一起结账延迟事故:五个动作里排除了四个嫌疑(冷 Redis 缓存、支付网关连接池、fraud-scorer sidecar、DNS),找到一条线索,然后步数用完。下一次运行先问记忆:调查已经确定了什么。把 scratchpad 作为文本交给 MemoryLake 的抽取器,线索每次都留下,排除结论只留下 0/32;续跑的计划在 96 个选择里重查了 26 次死路。每轮迭代用 fact add 写一条带类型的记录,全部留下,计划一次死路都没重查;但问到两个从没查过的嫌疑,模型有 29/47 次说已经排除。再加一条「其余都没排除」的覆盖记录,降到 0/48。
你会看到
- 同一个循环五种存法:Thought 为 TEXT、配
TOOL_USE/TOOL_RESULT块;scratchpad 整段为 TEXT;同上但每个结论都说出来(「… so X is ruled out」);每轮一条fact add记录;记录再加一条覆盖记录 - 续跑经
memorylake router chat --boundary提问:「挑接下来 4 个动作」,以及对四个查过、两个没查过的嫌疑问「调查是否已经排除 X?」;无记忆臂作为 ∅ 基线 - 8 次运行:记忆里留下的排除结论——工具块 0/32,scratchpad 0/32,说出结论 28/32,记录 32/32;记忆里没有结论却答 Yes,判为猜测,不算记住
memory子命令列出每种存法对每个嫌疑记住了什么,ask queries把反向问题问遍所有臂,另有本地 Web 界面
需要: 一个 MemoryLake API key · memorylake CLI · Python 3.9+
运行
git clone https://github.com/memorylake-ai/memorylake-usecases.git cd memorylake-usecases/ruled-out-memory export MEMORYLAKE_BASE_URL=https://app.memorylake.cn/openapi/memorylake export MEMORYLAKE_API_KEY=sk-… python3 demo.py # or: python3 web/server.py
看它跑起来 · 真实录制,未剪辑
相关场景
Engineering & Developer计划与执行代理的记忆Plan-and-execute agents lose the plan as execution drifts. MemoryLake pins the plan and tracks execution state in typed memory. Free to get started.
Engineering & Developer思维树代理的记忆Tree-of-Thoughts agents explore many branches. MemoryLake gives them branched persistent memory with merge and rollback. Free to get started.
Engineering & Developer反思风格自我改进代理的记忆Reflexion agents need persistent reflection memory to actually self-improve. MemoryLake provides it with typed reflection memory. Free to get started.
Engineering & Developer跨代理架构的记忆基准测试Comparing memory strategies across agent architectures needs controlled benchmarks. MemoryLake provides the substrate. Free to get started.
Engineering & Developer多步骤代理推理的记忆追踪Multi-step agent reasoning is hard to trace. MemoryLake links every reasoning step to the memory that drove it. Free to get started.
常见问题
紧凑的ReAct循环中的延迟?
紧凑的ReAct循环中的延迟?
单数字毫秒检索;可以忽略不计。
长ReAct追踪的存储成本?
长ReAct追踪的存储成本?
增量编码的提交保持低开销。
自托管?
自托管?
是的 — 企业级在您的VPC中部署。