Martian-Engineering /lossless-claw
Lossless Claw — LCM (Lossless Context Management) plugin for OpenClaw
★ 4,919⑂ 462👁 24⑃ 763● 560▤ 49
-3
日增长
4,919
stars
462
forks
24
watchers
763
prs
560
issues
49
releases
README
lossless-claw(無損上下文管理插件)
OpenClaw 的 DAG 式對話壓縮插件 — 讓 AI 記住一切,不再遺忘。
這是什麼
當對話超過模型的上下文窗口時,傳統做法是截斷舊訊息。lossless-claw 改用 DAG(有向無環圖)式摘要系統:
1. 持久化每條訊息 — 寫入 SQLite,按對話分組
2. 階層式摘要 — 將舊訊息壓縮成多層摘要,保留關鍵資訊
3. 智慧重建上下文 — 每次對話從摘要 DAG 中挑選最相關的節點
4. 零遺失 — 原始訊息永遠保留,可隨時展開還原
混搭模型支援
lossless-claw 支援主模型與摘要模型分離:
| 角色 | 模型範例 | 說明 |
|------|---------|------|
| 主模型 | Claude Opus / Sonnet | 處理對話 |
| LCM 摘要 | MiniMax M2.7 HS | 生成摘要,節省成本 |
| LCM 展開 | MiniMax M2.7 HS | 展開摘要細節 |
快速開始
bash
安裝
openclaw plugins install lossless-claw
啟用
openclaw plugins enable lossless-claw
設為上下文引擎
在 openclaw.json 中加入:
"plugins": { "slots": { "contextEngine": "lossless-claw" } }
配置範例(混搭 MiniMax M2.7 HS)
json
{
"plugins": {
"slots": {
"contextEngine": "lossless-claw"
},
"entries": {
"lossless-claw": {
"config": {
"summaryModel": "minimax/MiniMax-M2.7-highspeed",
"summaryProvider": "minimax",
"expansionModel": "minimax/MiniMax-M2.7-highspeed",
"expansionProvider": "minimax",
"contextThreshold": 0.75
}
}
}
}
}
整合重點
1. OpenClaw runtime.llm.complete
LCM 摘要現在透過 OpenClaw host-owned runtime.llm.complete 執行。lossless-claw 只提出摘要模型 override 請求;provider dispatch、憑證解析、OAuth refresh、usage attribution 都由 OpenClaw runtime 負責。
如果設定 summaryModel、largeFileSummaryModel 或 fallbackProviders,需要在 plugins.entries.lossless-claw.llm 中允許對應的 model override。
2. stripAuthErrors() 假陽性修復
分支: fix/summarize-strip-auth-false-positive
問題:壓縮包含 "401"/"authentication_error" 等字眼的對話時,pickAuthInspectionValue() 會將對話內容誤判為真正的 auth error,產生假的 [lcm] compaction failed: provider auth error 日誌。
根因:summarize.ts 第 390 行,當 regex 沒匹配到 auth-related key 時,fallback 回原始 value,導致下游 extractProviderAuthFailure() 從對話內容中誤偵測到 auth 失敗。
修復:改為回傳空物件 {},避免假陽性。
已驗證的部署配置
| 機器 | 主模型 | LCM 模型 | Summaries | 漂移 | Errors |
|------|--------|---------|-----------|------|--------|
| Scott4 | Claude Opus | M2.7 HS | 200+ | 零 | 零 |
| Scott2 | Claude Opus | M2.7 HS | 40+ | 零 | 零 |
相關倉庫
| 倉庫 | 說明 |
|------|------|
| Martian-Engineering/lossless-claw | 上游原始倉庫 |
| openclaw/openclaw | OpenClaw 主專案 |
| catgodtwno4/openclaw-five-layer-memory-nas | 五層記憶棧 NAS 部署指南 |
| catgodtwno4/openclaw-dashboard | OpenClaw Dashboard |
許可證
MITTop issues
#639BUG: Lossless-Claw: Dedup Fail-Closed and Deferred Compaction Loop12 comments · 2026-05-08#556Harden conversation identity integrity for session rotation10 comments · 2026-05-03#206[Bug] Thread/session fork copies full raw JSONL instead of LCM-compacted context — child session inherits unbounded history9 comments · 2026-03-29#620Per-agent scope policy for lcm_grep / lcm_describe / lcm_expand / lcm_expand_query8 comments · 2026-05-06#609afterTurn: bootstrap checkpoint refresh fails with ENOENT for sessions/<id>.jsonl on openclaw 2026.5.38 comments · 2026-05-05#191[SECURITY] Request a private channel for vulnerability disclosure8 comments · 2026-03-26#145lossless-claw 0.4.0 + Node 22.16.0 + OpenClaw 2026.3.13: plugin loads but no summaries written7 comments · 2026-03-20#708Images externalized by lossless-claw are not re-hydrated during context assembly — model cannot see pasted images6 comments · 2026-05-18
Latest release
v1.2.0 v1.2.0 2026-10-201.2.0 Minor Changes - 1238 99dfe43 Thanks @jalehman! - Ingest the OpenClaw transcript through a persisted per-conversation visible-delta cursor instead of re-reading and reconciling the whole transcript on every bootstrap and afterTurn. Steady-state turns now read only new transcript entries (about 2–5 ms with no main-thread SQLite work, down from 0.3–28.5 s on large sessions). - commitTurn, afterTurn, ingest and ingestBatch no longer persist runtime message arrays for transcript-backed sessions, so every new row carries its transcript entry id. commitTurn records its idempotency recei