Martian-Engineering/lossless-claw

Lossless Claw — LCM (Lossless Context Management) plugin for OpenClaw

lossless-claw – Lossless Context Management for OpenClaw

What it is

  • A plugin for the OpenClaw AI‑agent platform that replaces the default sliding‑window context truncation with a Lossless Context Management (LCM) system.
  • It stores every message in a SQLite database and builds a DAG of hierarchical summaries, so the model never loses information even when the token window is exceeded.

Key concepts

  1. Persistence – All raw messages are written to lcm.db (SQLite) and never deleted.
  2. Summarisation – Older chunks are summarised by a configured LLM; summaries are then condensed into higher‑level nodes, forming a directed‑acyclic graph.
  3. Context assembly – For each turn the plugin pulls recent raw messages plus the appropriate summary nodes to stay within the model’s token limit.
  4. Recall tools – Commands like lcm_grep, lcm_describe, and lcm_expand let agents search the compacted history and drill back into the original messages.

How you interact with it

  • CLI (lcm) – A shell‑style interface that reads the database (read‑only) and lets you inspect status, list conversations, tail messages, view summaries, and tweak a few config values (freshTailCount).
  • OpenClaw slash commands – In‑chat commands such as /lossless, /lossless backup, /lossless doctor, and /lossless status expose diagnostics, backup creation, health checks, and maintenance actions.
  • Programmatic contract – A minimal host‑facing API (status, doctor) for OpenClaw gateways that support context‑engine control.
  • Migration tool – lossless-claw-migrate-sessions imports existing OpenClaw JSONL session files into the LCM database (dry‑run first, optional --apply).

Installation & setup

# recommended – use OpenClaw’s plugin installer
openclaw plugins install @martian-engineering/lossless-claw@latest
  • Requires OpenClaw ≥ 2026.9.2 with plugin‑context‑engine support.
  • Node 22+ is needed.
  • An LLM provider must be configured in OpenClaw; the plugin calls that provider to generate summaries.

Configuration

  • Add a lossless-claw entry under plugins.entries in the OpenClaw JSON config (see README for a full example). Important knobs include:
    • freshTailCount – how many recent messages are protected from summarisation.
    • leafChunkTokens – token limit that triggers a leaf‑chunk summary.
    • summaryModel / expansionModel – which model to use for summarising and for expanding summaries.
    • Various thresholds (LCM_CONTEXT_THRESHOLD, LCM_PROACTIVE_THRESHOLD_COMPACTION_MODE, etc.) that control when compaction runs and whether it is performed inline or deferred.
  • Environment variables (prefixed LCM_) provide an alternative way to set the same options.

Maintenance workflow

  • The plugin records compaction debt when a conversation exceeds the token window.
  • /lossless doctor maintenance lists debt; /lossless doctor apply … attempts to repair broken summaries or close inactive debt after a backup.
  • Backups are created automatically before any write‑operation that could alter the database.

Why it matters

  • Traditional agents lose older turns, which can break long‑running or investigative dialogues.
  • lossless‑claw keeps the full conversation history searchable while still fitting within model limits, enabling “never‑forget” agents.
  • The DAG summarisation approach is lightweight (SQLite + LLM calls) and integrates cleanly with OpenClaw’s plugin architecture.

Where to learn more

  • Animated visualisation: https://losslesscontext.ai
  • CLI docs: docs/cli.md
  • Context explorer UI: Settings → Labs → Custom plugin UI in OpenClaw.

All details above are taken directly from the repository’s README.

Related

  • Project
  • Project
  • Project
  • Project
  • Project