记忆工具
记忆工具¶
config.toolsAllow 设置阻塞式子代理可以调用的具体工具名称,用于高级 Active Memory。Active Memory 按以下顺序选择工具:
- 有效且非空的显式
config.toolsAllow列表。 - 所选记忆提供方的
recallToolNames能力。 - 下面显示的内置回退。
| 记忆提供方 | 默认 toolsAllow |
|---|---|
| 内置记忆 | ["memory_search", "memory_get"] |
| LanceDB | ["memory_recall"] |
Memory Core 声明 ["memory_search", "memory_get"]。自定义记忆提供方可以注册自己的具体深度召回工具,并通过 recallToolNames 声明相同的名称。
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