# lossless-claw: DAG-based lossless context management for OpenClaw

> lossless-claw replaces OpenClaw's sliding-window truncation with a SQLite-backed summarization DAG that keeps every raw message and exposes recall tools to the agent. It is a plugin for people already running OpenClaw, not a standalone memory layer.

**Martian-Engineering/lossless-claw** — Lossless Claw — LCM (Lossless Context Management) plugin for OpenClaw

- Repository: https://github.com/Martian-Engineering/lossless-claw
- Stars: 4,903 · Forks: 455
- Language: TypeScript
- License: MIT
- Published: 2026-09-23 · Updated: 2026-09-23 · Language: en
- Canonical page: https://hysenlabs.com/projects/martian-engineering-lossless-claw

## What lossless-claw replaces inside OpenClaw

Every agent framework hits the same wall: the conversation outgrows the model's context window, and something has to give. OpenClaw's default answer is truncation. Older messages fall off the front of the window and are gone from the model's view. lossless-claw is a plugin that replaces that sliding-window compaction with a summarization system built on a directed acyclic graph.

The README states the design goal plainly: persist every message, summarize chunks of older messages, condense those summaries into higher-level nodes, and assemble each turn's context from summaries plus recent raw messages. The original text is never deleted. Summaries keep links back to the messages they came from, and three tools (lcm_grep, lcm_describe, lcm_expand) let the agent drill back into a summary to recover detail.

The audience is narrow and specific. This is for people who already run OpenClaw and configure it with an LLM provider, because summarization uses your configured model. It is not a memory library you import into your own agent. The repository is TypeScript, MIT licensed, and the plugin manifest sits at openclaw.plugin.json in the repository root.

## How the summarization DAG and context assembly work

The mechanism has four stages, and the interesting part is what happens as history accumulates rather than at the first compaction.

Messages land in a SQLite database (lcm.db), organized by conversation. When a conversation passes the model's token limit, lossless-claw summarizes a chunk of older messages into a summary node. As summaries pile up, they are condensed again into higher-level nodes, which is what makes the structure a DAG rather than a flat list: a node's children are the summaries or messages it was built from. Each turn, the context assembler walks that structure and combines summary nodes with a tail of recent raw messages.

The tail is a named, tunable quantity. The CLI exposes it as freshTailCount, and the README's own example sets it with lcm config set freshTailCount 96. That is the knob that decides how much verbatim recent conversation the model sees before it starts reading summaries.

Summaries are not opaque. The lcm_expand tool exists so an agent can open a summary and pull the underlying detail back into context, and lcm_grep searches across stored history. The README's claim is that raw messages stay in the database and summaries link back to their sources, which is what makes the word lossless defensible: nothing is discarded, only compressed for the model's view.

## Installing lossless-claw and checking it with lcm status

The README does not spell out a bare npm install line for the plugin itself. What it does document is the migration CLI, which runs through npx against the published package name, and a Dockerfile in the repository root that installs a locally built copy into an OpenClaw instance.

The Dockerfile is the most complete install path the repository gives. It builds on node:22-bookworm, installs OpenClaw globally, copies the plugin, runs the build, then installs the local plugin into the OpenClaw instance and starts the gateway in dev mode:

```dockerfile
FROM node:22-bookworm
RUN apt-get update && apt-get install -y git python3 make g++ cmake linux-libc-dev
RUN npm install -g openclaw@latest
WORKDIR /plugin
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
WORKDIR /root/.openclaw
RUN openclaw plugins install /plugin
ENTRYPOINT ["openclaw", "gateway", "run", "--dev", "--bind", "auto"]
```

Once the plugin is installed, the shell CLI is the fastest way to confirm it is reading a real database. The package publishes two binaries, lcm and lossless-claw-migrate-sessions, and the README gives this set of read commands:

```bash
lcm status
lcm conversations show --session-key 'agent:main:example'
lcm messages tail --conversation-id 42
lcm summaries list --conversation-id 42 --depth 0 --recency 7d
lcm config get freshTailCount
```

JSON is the default output, and list commands use bounded keyset pagination. If lcm status returns database path and size rather than an error, the plugin is wired up. The README states the CLI reads lcm.db without modifying conversation data, and that its only write command sets one validated Lossless config value in openclaw.json.

Inside a chat session, the native command surface gives you the operational view. /lossless reports version, enablement state, DB path and size, summary counts, and summary-health status. /lossless doctor scans for broken or truncated summaries. If you have existing OpenClaw JSONL session files from before the plugin was installed, the migration CLI backfills them, and the README is explicit that you should dry-run first:

## Compaction debt, doctor commands, and the failure mode to watch

The most interesting operational concept here is deferred compaction debt, and it is also where the design shows strain.

Debt means a conversation has accumulated history that needs summarizing and has not been summarized yet. The README splits it into two kinds. Debt on an active conversation is actionable maintenance pressure. Debt on an archived or inactive conversation is historical, and normal stable-session maintenance cannot select that conversation at all, so /lossless doctor maintenance reports it separately with a bounded set of recent examples.

Closing historical debt is deliberately awkward. It requires the exact confirm-inactive token and a successful file-backed SQLite backup, and the command is /lossless doctor apply maintenance <conversation-id> confirm-inactive. The README is careful about what that does: it records an operator-ignored resolution on the maintenance row only. It does not run compaction, and it does not delete or rewrite conversations, messages, summaries, or context items. If that conversation later generates genuine new debt, the administrative resolution is cleared and the row returns to pending. That is a sensible safety property, and it also means the command is bookkeeping, not repair.

The real repair path is /lossless doctor apply, which fixes broken summaries in the current conversation after a safety preflight. Repairing a specific conversation requires /lossless doctor apply <conversation-id> confirm-offline, and the README restricts targeted repair to authorized OpenClaw command senders and requires the channel path to be paused or moved away first. So the honest failure mode is this: if summaries break, you cannot fix them in place while the conversation is live. You take the conversation offline, confirm, and repair. Teams expecting hot repair will be disappointed.

There is also a read-only diagnostic, /lossless doctor clean, which surfaces high-confidence junk for archived subagents and cron sessions across every configured OpenClaw agent id, plus NULL-key orphaned subagent runs. It reports; it does not clean.

## Programmatic control is advertised but not yet reachable

The README describes an optional host-facing context-engine control contract for OpenClaw gateways that support context-engine capabilities and control dispatch. It is smaller than the slash command surface on purpose: status returns whether an LCM conversation is active and the current stored message count, and doctor returns a bounded, sanitized warning list for summary-health issues. Programmatic control never returns transcript text, local database paths, backup paths, credentials, provider debug, or shell output.

The catch is stated in the README itself. The surface is capability-gated by the OpenClaw host, and at the time of that change there was not yet a stable OpenClaw release with the required context-engine control endpoints. The README points to a pending OpenClaw contract (openclaw/openclaw#98060) or an equivalent downstream gateway. Treat the programmatic path as unavailable unless your host advertises the matching capability. If you are evaluating lossless-claw for automated orchestration, evaluate the slash commands and the lcm CLI instead, because those are what actually work today.

## lossless-claw against mem0 and other memory layers

The obvious comparison is a dedicated memory service such as mem0. The architectural difference is not cosmetic.

A memory layer like mem0 typically extracts facts from conversations and stores them as discrete memories, then retrieves relevant ones at query time. The conversation transcript itself is not the unit of storage; the extracted memory is. lossless-claw does the opposite. The transcript is the source of truth, stored in SQLite per conversation, and summaries are a derived index over it. Retrieval happens through lcm_grep, lcm_describe, and lcm_expand against that stored history, not against an extracted fact set.

That difference decides fit. If you want a portable memory API you can point any agent at, lossless-claw is the wrong shape: it is an OpenClaw plugin, and the README frames it as replacing OpenClaw's built-in compaction, not as a general memory backend. If you want the agent to be able to recover the exact phrasing of something said forty turns ago, the transcript-as-source-of-truth model is the one that can do it, provided the agent calls lcm_expand.

There is a cost on the other side. Summarization runs through your configured LLM, so every compaction cycle spends tokens on your provider, and the quality of recall depends on the quality of those summaries. A service that stores extracted facts avoids re-summarizing, but it also cannot give you the original text back.

## Licence, maintenance, and upgrade cost

The package is MIT licensed, and the repository root carries a LICENSE file alongside SECURITY.md and RELEASING.md. MIT is permissive: you can use, modify, and redistribute it, including in closed products, provided the copyright notice and licence text are retained. That is the general shape of the licence, not legal advice; read the LICENSE file for the actual terms.

The last push to the default branch was on 2026-09-22, and the most recent tagged release is v1.1.0 from 2026-09-19, following v1.0.0 on 2026-08-31. The repository is not archived. The release cadence visible in the repository is a 1.0 line that stabilized at the end of August and a 1.1 bump in mid-September, with beta releases before 1.0. There is a .changeset directory in the root, which is the Changesets workflow, so releases are versioned through changeset files rather than ad hoc tags.

Upgrade cost is mostly about the database and the config. The plugin persists conversations in lcm.db, and the README documents a backup command, /lossless backup, which creates a timestamped backup of the current LCM SQLite database. Run that before upgrading, because a schema change in a plugin that owns your conversation history is not something you want to discover without a copy. On the config side, the CLI's only write path touches one validated Lossless key in openclaw.json, which limits how much a bad command can damage your configuration. The README does not document a rollback procedure for a plugin version, so the backup is the rollback.

## Conclusion

Adopt lossless-claw if you already run OpenClaw and want older turns to stay retrievable instead of being truncated, and you accept that summarization runs through your configured LLM. Do not adopt it as a standalone memory service for another agent framework, and do not expect the programmatic context-engine control contract to work today, since the README states no stable OpenClaw release has the required endpoints. Before trusting it, run lcm status, then /lossless doctor and /lossless doctor maintenance on one active conversation, and confirm the debt rows that come back match what you expect.

## FAQ

### What is lossless-claw used for?

It replaces OpenClaw's sliding-window compaction with DAG-based summarization so that older messages are summarized rather than truncated, while every raw message stays in a SQLite database. Agents can then search and expand compacted history with the lcm_grep, lcm_describe, and lcm_expand tools.

### How do I install lossless-claw?

The README does not give a bare install command for the plugin. The repository's Dockerfile shows the full path: install OpenClaw globally, copy the plugin, run npm run build, then run openclaw plugins install /plugin. The migration CLI is run through npx against @martian-engineering/lossless-claw@latest.

### Is lossless-claw an alternative to mem0?

They store different things. lossless-claw keeps the conversation transcript in SQLite as the source of truth and derives summaries from it, while a memory layer like mem0 extracts facts and retrieves those. lossless-claw is an OpenClaw plugin, so it is not a portable memory backend for other agent frameworks.

### Which OpenClaw memory option is the best?

The README does not rank OpenClaw memory options, so there is no basis for a comparison. What it does state is what lossless-claw changes: it replaces the built-in sliding-window compaction with summarization that preserves every message in lcm.db.

## Sources

- [Issues](https://github.com/Martian-Engineering/lossless-claw/issues)
- [License: MIT](https://github.com/Martian-Engineering/lossless-claw/blob/main/LICENSE)
- [Martian-Engineering/lossless-claw on GitHub](https://github.com/Martian-Engineering/lossless-claw)
- [README](https://github.com/Martian-Engineering/lossless-claw/blob/main/README.md)
- [Releases](https://github.com/Martian-Engineering/lossless-claw/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/martian-engineering-lossless-claw
