乐于分享
好东西不私藏

OpenClaw配置contextengine插件lossless-claw

OpenClaw配置contextengine插件lossless-claw
前言

openclaw从3.7版本开始支持contextengine,该功能解决了context上下文周期管理的问题,保证长周期对话产生关键信息丢失的问题。

检查环境

首先保证openclaw版本大于3.7,nodebjs大于22.0.0, SQLite>3.4.0,备份当前的openclaw.json

openclaw --version 

node -v 

sqlite3 --version 

cp /root/.openclaw/opeclaw.json /home/ubuntu/openclaw.json.bak

安装插件

openclaw plugins install @martian-engineering/lossless-claw

编辑openclaw.json文件

增加如下配置:

"plugins": {    "slots": {      "contextEngine": "lossless-claw"    },    "entries": {      "lossless-claw": {        "enabled": true,        "config": {          "freshTailCount": 32,          "incrementalMaxDepth": -1,          "contextThreshold": 0.75        }      }    },

配置项说明:

配置项
默认值
说明
freshTailCount
32
保留最新 N 条原始消息不压缩
incrementalMaxDepth
-1
摘要树最大深度,-1 表示无限制
contextThreshold
0.75
上下文占用超过 75% 时触发压缩
检查确认:

openclaw doctor   检查配置是否没有问题,没有问题重启gateway 

openclaw gateway restart 

tail -f /tmp/openclaw/openclaw-$(date +%F).log | grep -i lossless 检查是否有输出,如果有表示配置已经生效。

后记

contextengine插件以及和向量存储,memory backend功能如何配合使用后续会使用单独章节来描述。