核心思路1、使用 qmd 减少上下文注入2、使用本地模型做心跳3、尽量走模型订阅而不是按次收费4、和自己的 claw 商量让它列出 token 消耗的清单和它讨论优化的可能性本文重点介绍qmd的安装使用以及多agengts下qmd如何配置QMD安装# 安装qmdsudoaptupdate# qmd 会使用sqlite3存储数据sudoaptinstallsqlite3 sqlite3--version# 使用 npm 安装npminstall-gtobilu/qmd qmd--version# 全局安装clawhubinstallqmd# 给指定agent安装clawhubinstallqmd--dir/home/cobrew/.openclaw/workspace-finance_agent/skills配置qmd// 全局配置{memory:{backend:qmd,qmd:{limits:{timeoutMs:10000}}}}详细配置参考官网https://docs.openclaw.ai/reference/memory-config#memory-configuration-reference{memory:{backend:qmd,citations:auto,qmd:{includeDefaultMemory:true,update:{interval:5m,debounceMs:15000},limits:{maxResults:6,timeoutMs:4000},scope:{default:deny,rules:[{action:allow,match:{chatType:direct}},// Normalized session-key prefix (strips agent:id:).{action:deny,match:{keyPrefix:discord:channel:}},// Raw session-key prefix (includes agent:id:).{action:deny,match:{rawKeyPrefix:agent:main:discord:}},]},paths:[{name:docs,path:~/notes,pattern:**/*.md}]}}}重启gateway# 重启 OpenClaw Gateway 服务openclaw gateway restart配置成功的效果如下通过命令查看cobrewDESKTOP-9449JCG:~/.openclaw$ openclaw memory status OpenClaw2026.3.13(61d171a)— Shell yeah—Im here to pinch the toil and leave you the glory.22:50:45[plugins]plugins.allow is empty;discovered non-bundled plugins may auto-load: feishu(/home/cobrew/.npm-global/lib/node_modules/openclaw/extensions/feishu/index.ts). Set plugins.allow to explicit trusted ids.22:51:13[plugins]feishu_doc: Registered feishu_doc, feishu_app_scopes22:51:13[plugins]feishu_chat: Registered feishu_chat tool22:51:13[plugins]feishu_wiki: Registered feishu_wiki tool22:51:13[plugins]feishu_drive: Registered feishu_drive tool22:51:13[plugins]feishu_bitable: Registered bitable tools Memory Search(main)Provider: qmd(requested: qmd)Model: qmd Sources: memory Indexed:0/0 files ·0chunks Dirty: no Store: ~/.openclaw/agents/main/qmd/xdg-cache/qmd/index.sqlite Workspace: ~/.openclaw/workspace By source: memory ·0/0 files ·0chunks Vector: ready Batch: disabled(failures0/0)Issues: no memory files foundin~/.openclaw/workspace Memory Search(finance_agent)Provider: qmd(requested: qmd)Model: qmd Sources: memory Indexed:4/4 files ·4chunks Dirty: no Store: ~/.openclaw/agents/finance_agent/qmd/xdg-cache/qmd/index.sqlite Workspace: ~/.openclaw/workspace-finance_agent By source: memory ·4/4 files ·4chunks Vector: ready Batch: disabled(failures0/0)Memory Search(code_agent)Provider: qmd(requested: qmd)Model: qmd Sources: memory Indexed:0/0 files ·0chunks Dirty: no Store: ~/.openclaw/agents/code_agent/qmd/xdg-cache/qmd/index.sqlite Workspace: ~/.openclaw/workspace-code_age By source: memory ·0/0 files ·0chunks Vector: ready Batch: disabled(failures0/0)Issues: no memory files foundin~/.openclaw/workspace-code_age cobrewDESKTOP-9449JCG:~/.openclaw$qmd命令# 查看 QMD 版本qmd--version# 查看 QMD 全局配置qmd config show# 检查 QMD 服务状态OpenClaw 集成版openclaw memory status# 手动刷新某个 Agent 的 QMD 索引核心命令openclaw memory refresh--agent[agent-id]# 例openclaw memory refresh --agent finance_agent# 列出某个 Agent 的 QMD 索引文件qmd index list--dir~/.openclaw/agents/[agent-id]/qmd/# 清空某个 Agent 的 QMD 索引仅测试/重置用qmd indexclear--dir~/.openclaw/agents/[agent-id]/qmd/--force# 模拟某个 Agent 检索关键词最常用的隔离验证openclaw memory query--agent[agent-id]检索关键词# 例openclaw memory query --agent finance_agent 项目代号# 直接调用 QMD 检索指定目录底层验证qmd query检索关键词--dir~/.openclaw/agents/[agent-id]/qmd/# 列出所有 Agent 的 QMD 独立目录直观验证隔离ls-la~/.openclaw/agents/*/qmd/# 查看某个 Agent 的 QMD 索引大小排查存储du-sh~/.openclaw/agents/[agent-id]/qmd/# 查看 QMD 检索日志定位隔离/检索问题openclaw logs--filterqmd--agent[agent-id]# 实时监控 QMD 日志openclaw logs--follow--filterqmd
openclaw优化Token消耗攻略
核心思路1、使用 qmd 减少上下文注入2、使用本地模型做心跳3、尽量走模型订阅而不是按次收费4、和自己的 claw 商量让它列出 token 消耗的清单和它讨论优化的可能性本文重点介绍qmd的安装使用以及多agengts下qmd如何配置QMD安装# 安装qmdsudoaptupdate# qmd 会使用sqlite3存储数据sudoaptinstallsqlite3 sqlite3--version# 使用 npm 安装npminstall-gtobilu/qmd qmd--version# 全局安装clawhubinstallqmd# 给指定agent安装clawhubinstallqmd--dir/home/cobrew/.openclaw/workspace-finance_agent/skills配置qmd// 全局配置{memory:{backend:qmd,qmd:{limits:{timeoutMs:10000}}}}详细配置参考官网https://docs.openclaw.ai/reference/memory-config#memory-configuration-reference{memory:{backend:qmd,citations:auto,qmd:{includeDefaultMemory:true,update:{interval:5m,debounceMs:15000},limits:{maxResults:6,timeoutMs:4000},scope:{default:deny,rules:[{action:allow,match:{chatType:direct}},// Normalized session-key prefix (strips agent:id:).{action:deny,match:{keyPrefix:discord:channel:}},// Raw session-key prefix (includes agent:id:).{action:deny,match:{rawKeyPrefix:agent:main:discord:}},]},paths:[{name:docs,path:~/notes,pattern:**/*.md}]}}}重启gateway# 重启 OpenClaw Gateway 服务openclaw gateway restart配置成功的效果如下通过命令查看cobrewDESKTOP-9449JCG:~/.openclaw$ openclaw memory status OpenClaw2026.3.13(61d171a)— Shell yeah—Im here to pinch the toil and leave you the glory.22:50:45[plugins]plugins.allow is empty;discovered non-bundled plugins may auto-load: feishu(/home/cobrew/.npm-global/lib/node_modules/openclaw/extensions/feishu/index.ts). Set plugins.allow to explicit trusted ids.22:51:13[plugins]feishu_doc: Registered feishu_doc, feishu_app_scopes22:51:13[plugins]feishu_chat: Registered feishu_chat tool22:51:13[plugins]feishu_wiki: Registered feishu_wiki tool22:51:13[plugins]feishu_drive: Registered feishu_drive tool22:51:13[plugins]feishu_bitable: Registered bitable tools Memory Search(main)Provider: qmd(requested: qmd)Model: qmd Sources: memory Indexed:0/0 files ·0chunks Dirty: no Store: ~/.openclaw/agents/main/qmd/xdg-cache/qmd/index.sqlite Workspace: ~/.openclaw/workspace By source: memory ·0/0 files ·0chunks Vector: ready Batch: disabled(failures0/0)Issues: no memory files foundin~/.openclaw/workspace Memory Search(finance_agent)Provider: qmd(requested: qmd)Model: qmd Sources: memory Indexed:4/4 files ·4chunks Dirty: no Store: ~/.openclaw/agents/finance_agent/qmd/xdg-cache/qmd/index.sqlite Workspace: ~/.openclaw/workspace-finance_agent By source: memory ·4/4 files ·4chunks Vector: ready Batch: disabled(failures0/0)Memory Search(code_agent)Provider: qmd(requested: qmd)Model: qmd Sources: memory Indexed:0/0 files ·0chunks Dirty: no Store: ~/.openclaw/agents/code_agent/qmd/xdg-cache/qmd/index.sqlite Workspace: ~/.openclaw/workspace-code_age By source: memory ·0/0 files ·0chunks Vector: ready Batch: disabled(failures0/0)Issues: no memory files foundin~/.openclaw/workspace-code_age cobrewDESKTOP-9449JCG:~/.openclaw$qmd命令# 查看 QMD 版本qmd--version# 查看 QMD 全局配置qmd config show# 检查 QMD 服务状态OpenClaw 集成版openclaw memory status# 手动刷新某个 Agent 的 QMD 索引核心命令openclaw memory refresh--agent[agent-id]# 例openclaw memory refresh --agent finance_agent# 列出某个 Agent 的 QMD 索引文件qmd index list--dir~/.openclaw/agents/[agent-id]/qmd/# 清空某个 Agent 的 QMD 索引仅测试/重置用qmd indexclear--dir~/.openclaw/agents/[agent-id]/qmd/--force# 模拟某个 Agent 检索关键词最常用的隔离验证openclaw memory query--agent[agent-id]检索关键词# 例openclaw memory query --agent finance_agent 项目代号# 直接调用 QMD 检索指定目录底层验证qmd query检索关键词--dir~/.openclaw/agents/[agent-id]/qmd/# 列出所有 Agent 的 QMD 独立目录直观验证隔离ls-la~/.openclaw/agents/*/qmd/# 查看某个 Agent 的 QMD 索引大小排查存储du-sh~/.openclaw/agents/[agent-id]/qmd/# 查看 QMD 检索日志定位隔离/检索问题openclaw logs--filterqmd--agent[agent-id]# 实时监控 QMD 日志openclaw logs--follow--filterqmd