记忆工具
记忆工具¶
config.toolsAllow 设置阻塞式子代理为了高级 Active Memory 可以调用的具体工具名称。默认值取决于当前记忆提供方:
| 记忆提供方 | 默认 toolsAllow |
|---|---|
| 内置记忆 | ["memory_search", "memory_get"] |
| LanceDB | ["memory_recall"] |
toolsAllow 是一种限制,而非授权许可。在开始召回之前,Active Memory 会通过父代理最终确定的工具策略过滤这些名称。插件可以注册一个父代理所选配置文件排除的工具。使用显式的 tools.alsoAllow 条目来扩展受限配置文件,如 Lossless Claw 示例 所示。这些授权也会让父代理能够访问指定的工具;它们并非仅限召回的权限。显式拒绝以及提供方、代理和沙箱限制仍然适用,并且当父轮的工具权限过期后,召回无法继续。
如果仅允许部分已配置的工具,召回仍然可以使用这一较小的集合运行。例如,即使排除了 Lossless Claw 工具,memory_search 仍可能保持可用。
如果配置的工具均不可用,或者子代理运行失败,Active Memory 会跳过该轮的召回,主回复将在没有记忆上下文的情况下继续。对于自定义召回工具,非空的模型可见工具输出可视为召回证据,除非结构化结果字段明确报告了空结果或失败。
toolsAllow 仅接受具体的记忆工具名称:通配符、group:* 条目以及核心代理工具(read、exec、message、web_search 等)都会在隐藏子代理启动前被静默过滤掉。
内置记忆¶
无需显式 toolsAllow:
{
plugins: {
entries: {
"active-memory": {
enabled: true,
config: {
agents: ["main"],
// Default: ["memory_search", "memory_get"]
},
},
},
},
}
LanceDB 记忆¶
在安装并配置 LanceDB 之后,Active Memory 会自动使用 memory_recall;无需显式 toolsAllow:
{
plugins: {
entries: {
"active-memory": {
enabled: true,
config: {
agents: ["main"],
promptAppend: "Use memory_recall for long-term user preferences, past decisions, and previously discussed topics. If recall finds nothing useful, return NONE.",
},
},
},
},
}
这是针对 LanceDB 自身存储记忆的高级 Active Memory 路径。memory.search.rememberAcrossConversations 不会通过 memory_recall 暴露私有会话记录。当 LanceDB 是当前记忆提供方时,请使用 LanceDB 的自动召回或上述高级配置。
Lossless Claw¶
Lossless Claw 是一个外部上下文引擎插件(openclaw plugins install @martian-engineering/lossless-claw),拥有自己的召回工具。请先将其设置为上下文引擎;参见上下文引擎。然后将其召回工具授予父代理,并让 Active Memory 指向这些工具。此示例将 main 代理保持在受限的 coding 配置文件上,并通过 agents.entries.main.tools.alsoAllow 仅添加三个指定的 Lossless Claw 工具。请将这些条目合并到该代理现有的工具配置中。保留你选择的配置文件以及任何其他必需的授权和拒绝。此示例假设代理作用域中没有同时定义 tools.allow:allow 和 alsoAllow 不能在同一作用域中组合使用。后续的允许列表无法恢复被配置文件排除的工具。在改造现有分层允许列表之前,请参阅工具策略:
{
agents: {
entries: {
main: {
tools: {
profile: "coding",
alsoAllow: ["lcm_grep", "lcm_describe", "lcm_expand_query"],
},
},
},
},
plugins: {
slots: {
contextEngine: "lossless-claw",
},
entries: {
"lossless-claw": {
enabled: true,
},
"active-memory": {
enabled: true,
config: {
agents: ["main"],
toolsAllow: ["memory_search", "lcm_grep", "lcm_describe", "lcm_expand_query"],
promptAppend: "Use lcm_grep first for compacted conversation recall. Use lcm_describe to inspect a specific summary. Use lcm_expand_query only when the latest user message needs exact details that may have been compacted away. Return NONE if the retrieved context is not clearly useful.",
},
},
},
},
}
不要在此处将 lcm_expand 添加到 toolsAllow;Lossless Claw 将其用作委托扩展的底层工具,并非面向顶层 active-memory 子代理。Lossless Claw 会改变上下文组装方式,但不会替换当前记忆提供方。当同时使用 rememberAcrossConversations 时,请在 toolsAllow 中保留 memory_search;仅包含 LCM 工具的工具列表对于高级 Active Memory 仍然有效,但会禁用产品级会话记录召回路径。
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 cl/openclaw