Active memory 是一个可选的、由插件拥有的阻塞式内存子代理,它会在符合条件的对话会话中于主回复生成之前运行。 它之所以存在,是因为大多数记忆系统虽然功能强大,但都是被动的。它们依赖主代理决定何时搜索记忆,或者依赖用户说出诸如“记住这个”或“搜索记忆”之类的话。到了那时,记忆本可以让回复显得自然的那个时刻,已经过去了。 Active memory 给系统提供了一次有限的机会,在主回复生成前浮现相关记忆。Documentation Index
Fetch the complete documentation index at: https://openclaw.zhcndoc.com/llms.txt
Use this file to discover all available pages before exploring further.
快速开始
将以下内容粘贴到openclaw.json 中,作为安全默认配置——启用插件,仅作用于 main 代理,仅限直接消息会话,并在可用时继承会话模型:
plugins.entries.active-memory.enabled: true会开启插件config.agents: ["main"]只让main代理使用 active memoryconfig.allowedChatTypes: ["direct"]将其限定为直接消息会话(群组/频道需显式加入)config.model(可选)会固定一个专用回忆模型;不设置则继承当前会话模型config.modelFallback仅在没有显式或继承模型可用时使用config.promptStyle: "balanced"是recent模式下的默认值- Active memory 仍然只会在符合条件的交互式持久聊天会话中运行
速度建议
最简单的配置是让config.model 保持未设置状态,并让 Active Memory 使用你平时用于正常回复的同一模型。这是最安全的默认方式,因为它会沿用你现有的提供商、认证和模型偏好。
如果你希望 Active Memory 更快,可以使用专用推理模型,而不是借用主聊天模型。回忆质量很重要,但对主回答路径来说,延迟比它更重要,而且 Active Memory 的工具面很窄(它只会调用可用的记忆回忆工具)。
推荐的快速模型选项:
cerebras/gpt-oss-120b,作为专用的低延迟回忆模型google/gemini-3-flash,作为低延迟后备,而不改变你的主聊天模型- 你的常规会话模型,只需让
config.model保持未设置
Cerebras 配置
添加一个 Cerebras 提供商,并将 Active Memory 指向它:chat/completions 访问权限——仅能看到 /v1/models 并不保证这一点。
如何查看
Active memory 会为模型注入一个隐藏的、不受信任的提示前缀。它不会在普通客户端可见回复中暴露原始的<active_memory_plugin>...</active_memory_plugin> 标签。
会话开关
当你想在不编辑配置的情况下暂停或恢复当前聊天会话中的 active memory 时,请使用插件命令:plugins.entries.active-memory.enabled、代理目标,或其他全局配置。
如果你希望命令写入配置,并为所有会话暂停或恢复 active memory,请使用显式的全局形式:
plugins.entries.active-memory.config.enabled。它会保留
plugins.entries.active-memory.enabled 为开启状态,这样该命令以后仍然可用,以便重新打开 active memory。
如果你想查看 active memory 在实时会话中的行为,请开启与你想要输出相匹配的会话开关:
- 一条 active memory 状态行,例如
Active Memory: status=ok elapsed=842ms query=recent summary=34 chars,当使用/verbose on - 一条可读的调试摘要,例如
Active Memory Debug: Lemon pepper wings with blue cheese.,当使用/trace on
/trace raw,被跟踪的 Model Input (User Role) 块会将隐藏的 Active Memory 前缀显示为:
运行时机
Active memory 使用两个门槛:- 配置显式启用
插件必须开启,并且当前代理 id 必须出现在
plugins.entries.active-memory.config.agents中。 - 严格的运行时资格 即使已启用并且已指定目标,active memory 也只会在符合条件的 交互式持久聊天会话中运行。
会话类型
config.allowedChatTypes 控制哪些类型的对话可以运行 Active
Memory。
默认值是:
config.allowedChatIds 和
config.deniedChatIds。
allowedChatIds 是解析后对话 id 的显式允许名单。当它
非空时,只有当会话的对话 id 在该列表中,Active Memory 才会运行。
这会一次性缩小所有允许的聊天类型范围,包括直接消息。如果你想要所有直接消息,以及仅某些群组,请将直接对端 id 包含在 allowedChatIds 中,或者将 allowedChatTypes 只聚焦于你正在测试的群组/频道放量。
deniedChatIds 是显式拒绝名单。它总是优先于
allowedChatTypes 和 allowedChatIds,因此即使某个对话的会话类型原本允许,只要匹配也会被跳过。
这些 id 来自持久频道会话键:例如飞书的 chat_id / open_id、Telegram 的 chat id,或 Slack 的 channel id。匹配不区分大小写。如果 allowedChatIds 非空,而 OpenClaw 无法为该会话解析出对话 id,Active Memory 会跳过该轮,而不是猜测。
示例:
运行位置
Active memory 是一个对话增强功能,而不是平台级推理功能。| Surface | Runs active memory? |
|---|---|
| Control UI / web chat persistent sessions | Yes, if the plugin is enabled and the agent is targeted |
| Other interactive channel sessions on the same persistent chat path | Yes, if the plugin is enabled and the agent is targeted |
| Headless one-shot runs | No |
| Heartbeat/background runs | No |
Generic internal agent-command paths | No |
| Sub-agent/internal helper execution | No |
为什么使用它
在以下情况下使用 active memory:- 会话是持久化的,并且面向用户
- 代理拥有有意义的长期记忆可供搜索
- 连贯性和个性化比原始提示词确定性更重要
- 稳定偏好
- 反复出现的习惯
- 应当自然浮现的长期用户上下文
- 自动化
- 内部工作器
- 一次性 API 任务
- 隐式个性化会显得突兀的场景
它是如何工作的
运行时结构如下: 阻塞式记忆子代理只能使用可用的记忆召回工具:memory_recallmemory_searchmemory_get
NONE。
查询模式
config.queryMode 控制阻塞式记忆子代理能看到多少对话内容。
请选择仍能很好回答后续问题的最小模式;超时时间预算应随着上下文大小增加(message < recent < full)。
- message
- recent
- full
只发送最新的用户消息。在以下情况下使用:
- 你想要最快的行为
- 你想要最强的稳定偏好召回倾向
- 后续轮次不需要对话上下文
config.timeoutMs 建议从 3000 到 5000 ms 开始。提示词样式
config.promptStyle 控制阻塞式记忆子代理在决定是否返回记忆时的积极程度或严格程度。
可用样式:
balanced:recent模式的通用默认值strict:最不积极;当你希望附近上下文泄漏最少时最合适contextual:最注重连贯性;当对话历史更重要时最合适recall-heavy:更愿意在较弱但仍然合理的匹配下展示记忆precision-heavy:除非匹配明显,否则强烈倾向于NONEpreference-only:针对喜好、习惯、例行模式、品味和重复出现的个人事实进行了优化
config.promptStyle 时的默认映射:
config.promptStyle,则该覆盖项优先生效。
示例:
模型回退策略
如果未设置config.model,Active Memory 会按以下顺序解析模型:
config.modelFallback 控制已配置的回退步骤。
可选的自定义回退:
config.modelFallbackPolicy 仅保留为旧配置的弃用兼容字段。它不再改变运行时行为。
高级逃生口
这些选项是有意不作为推荐设置的一部分。config.thinking 可以覆盖阻塞式记忆子代理的思考级别:
config.promptAppend 会在默认 Active Memory 提示词之后、对话上下文之前添加额外的操作指令:
config.promptOverride 会替换默认的 Active Memory 提示词。OpenClaw 仍会在之后追加对话上下文:
NONE 或简洁的用户事实上下文。
转录持久化
Active memory 阻塞式记忆子代理在调用期间会创建一个真实的session.jsonl 转录文件。
默认情况下,该转录文件是临时的:
- 会写入临时目录
- 只用于该次阻塞式记忆子代理运行
- 运行结束后会立即删除
config.transcriptDir 更改相对子目录。
请谨慎使用:
- 阻塞式记忆子代理转录文件在繁忙会话中可能很快累积
full查询模式会重复大量对话上下文- 这些转录文件包含隐藏提示上下文和召回的记忆
配置
所有 active memory 配置都位于:| Key | Type | Meaning |
|---|---|---|
enabled | boolean | Enables the plugin itself |
config.agents | string[] | Agent ids that may use active memory |
config.model | string | Optional blocking memory sub-agent model ref; when unset, active memory uses the current session model |
config.allowedChatTypes | ("direct" | "group" | "channel")[] | Session types that may run Active Memory; defaults to direct-message style sessions |
config.allowedChatIds | string[] | Optional per-conversation allowlist applied after allowedChatTypes; non-empty lists fail closed |
config.deniedChatIds | string[] | Optional per-conversation denylist that overrides allowed session types and allowed ids |
config.queryMode | "message" | "recent" | "full" | Controls how much conversation the blocking memory sub-agent sees |
config.promptStyle | "balanced" | "strict" | "contextual" | "recall-heavy" | "precision-heavy" | "preference-only" | Controls how eager or strict the blocking memory sub-agent is when deciding whether to return memory |
config.thinking | "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "adaptive" | "max" | Advanced thinking override for the blocking memory sub-agent; default off for speed |
config.promptOverride | string | Advanced full prompt replacement; not recommended for normal use |
config.promptAppend | string | Advanced extra instructions appended to the default or overridden prompt |
config.timeoutMs | number | Hard timeout for the blocking memory sub-agent, capped at 120000 ms |
config.setupGraceTimeoutMs | number | Advanced extra setup budget before the recall timeout expires; defaults to 0 and is capped at 30000 ms. See Cold-start grace for v2026.4.x upgrade guidance |
config.maxSummaryChars | number | Maximum total characters allowed in the active-memory summary |
config.logging | boolean | Emits active memory logs while tuning |
config.persistTranscripts | boolean | Keeps blocking memory sub-agent transcripts on disk instead of deleting temp files |
config.transcriptDir | string | Relative blocking memory sub-agent transcript directory under the agent sessions folder |
| 键 | 类型 | 含义 |
|---|---|---|
config.maxSummaryChars | number | active-memory 摘要允许的最大总字符数 |
config.recentUserTurns | number | 当 queryMode 为 recent 时要包含的之前用户轮次 |
config.recentAssistantTurns | number | 当 queryMode 为 recent 时要包含的之前助手轮次 |
config.recentUserChars | number | 每个最近用户轮次的最大字符数 |
config.recentAssistantChars | number | 每个最近助手轮次的最大字符数 |
config.cacheTtlMs | number | 对重复的相同查询进行缓存复用(范围:1000-120000 ms;默认:15000) |
config.circuitBreakerMaxTimeouts | number | 对同一代理/模型连续超时达到此次数后跳过召回。成功召回或冷却时间结束后重置(范围:1-20;默认:3)。 |
config.circuitBreakerCooldownMs | number | 熔断触发后跳过召回的时长,单位 ms(范围:5000-600000;默认:60000)。 |
推荐配置
从recent 开始。
/verbose on 查看
正常状态行,或使用 /trace on 查看 active-memory 调试摘要,
而不是去找单独的 active-memory 调试命令。在聊天频道中,这些诊断行会在主助手回复之后发送,而不是之前。
然后切换到:
- 如果你想要更低延迟,使用
message - 如果你认为额外上下文值得接受更慢的阻塞式 memory 子代理,使用
full
冷启动宽限
在 v2026.5.2 之前,插件会在冷启动期间默默将你配置的timeoutMs 额外延长
30000 毫秒,这样模型预热、embedding 索引加载以及
首次 recall 就可以共用一个更大的预算。v2026.5.2 将这段宽限移到了一个显式的
setupGraceTimeoutMs 配置之后——默认情况下,你配置的 timeoutMs
现在就是预算,除非你主动启用它。
如果你是从 v2026.4.x 升级而来,并且你把 timeoutMs 设为了适配
旧的隐式宽限世界的值(推荐的入门 timeoutMs: 15000 就是一个
例子),请设置 setupGraceTimeoutMs: 30000,以将 prompt-build hook 和
外层 watchdog 的预算恢复到 v5.2 之前的有效值:
setupGraceTimeoutMs 配置之后,因此插件不再会悄悄把主通道上的
15000 毫秒配置延长到 45000 毫秒。”
嵌入式 recall 运行器使用相同的有效超时预算,因此
setupGraceTimeoutMs 同时覆盖外层的 prompt-build watchdog 和内层的
阻塞式 recall 运行。
对于资源紧张且冷启动延迟是已知取舍的网关,较低的值(5000–15000 毫秒)也可行——
代价是网关重启后第一次 recall 在预热完成前返回空结果的概率更高。
调试
如果 active memory 没有出现在你预期的位置:- 确认插件已在
plugins.entries.active-memory.enabled下启用。 - 确认当前 agent id 已列在
config.agents中。 - 确认你是在交互式持久聊天会话中进行测试。
- 打开
config.logging: true并查看网关日志。 - 使用
openclaw memory status --deep验证 memory search 本身是否正常工作。
maxSummaryChars
- 降低
queryMode - 降低
timeoutMs - 减少 recent turn counts
- 减少每轮字符上限
常见问题
Active Memory 依赖于所配置的 memory 插件的 recall 流水线,因此大多数 recall 异常其实是 embedding provider 的问题,而不是 Active Memory 的 bug。 默认的memory-core 路径使用 memory_search;memory-lancedb 使用
memory_recall。
Embedding provider 切换了或停止工作
Embedding provider 切换了或停止工作
如果
memorySearch.provider 未设置,OpenClaw 会自动检测第一个
可用的 embedding provider。新的 API key、配额耗尽,或受速率限制的托管 provider,
可能会导致不同运行之间解析到不同的 provider。如果没有可解析的 provider,
memory_search 可能会退化为仅词法检索;一旦运行时已经选定 provider,发生故障后不会自动回退。请显式固定 provider(以及可选的 fallback),以使选择具有确定性。
有关完整的 provider 列表和固定示例,请参见 Memory Search。Recall 感觉缓慢、为空,或不一致
Recall 感觉缓慢、为空,或不一致
- 打开
/trace on,以在会话中显示由插件拥有的 Active Memory 调试摘要。 - 打开
/verbose on,以便在每次回复后还看到🧩 Active Memory: ...状态行。 - 查看网关日志中的
active-memory: ... start|done、memory sync failed (search-bootstrap),或 provider embedding 错误。 - 运行
openclaw memory status --deep检查 memory-search 后端 和索引健康状态。 - 如果你使用
ollama,请确认已安装 embedding 模型 (ollama list)。
网关重启后的首次 recall 返回 `status=timeout`
网关重启后的首次 recall 返回 `status=timeout`
在 v2026.5.2 及更高版本中,如果冷启动初始化(模型预热 + embedding
索引加载)在第一次 recall 触发时还没有完成,运行就可能达到已配置的
timeoutMs 预算并返回 status=timeout,且输出为空。网关日志会在重启后
首个符合条件的回复附近显示 active-memory timeout after Nms。请参见“推荐配置”下的 冷启动宽限 以获取
推荐的 setupGraceTimeoutMs 值。