oh-my-clm: Mirroring Editable Context to Files, Organized by the Model

Introduction

When running long tasks in DeepSeek Harness (DSH) or Pi, the conversation history grows continuously: tool outputs, repetitive reasoning, and outdated intermediate conclusions fill up the context window. Common approaches rely on the host’s native compaction or manual JSONL editing outside the session. Facebook Research’s context-language-models proposes an alternative approach: projecting the “current editable context” into a plain file, allowing the model to delete stale content via structured edits, rather than initiating a dedicated compact LLM turn.

Below is an introduction to the community plugin oh-my-clm (maintainer DevZjQx): the same core implementation is released as both a Pi extension and a DSH/Cordis plugin, categorized under “Memory” in the DSH community directory. See the repository on GitHub and the directory page on SkillHub.

What is this

oh-my-clm is a directly loadable live-context extension: when the host constructs the projection for the next request, it mirrors the editable portion into the current session’s temporary directory (e.g., /tmp/clm-${sessionId}/LIVE_CTX_MAIN.md). The model shortens the history via the cleanup tool or via mirror read/write within the same tool call; valid changes are persisted via the host’s native context edit at the end of the turn, without rewriting the original session JSONL.

The npm package name is oh-my-clm, and the version in the current documentation is 0.1.12. Pi and DSH can install it from npm or GitHub. DSH does not read Pi’s settings, and installations on both sides do not affect each other.

Core Mechanism

Mirror Files and Block Structure

Each session uses an independent temporary directory, ensuring that mirrors do not overwrite each other when sharing a working directory across multiple sessions. Inside the file, the clm-v2 protocol marks editable blocks, for example:

<!-- clm-v2 -->
<!-- CLM_SNAPSHOT ... -->

[[CLM_ENTRY id=1 role=assistant]]
This old content can be rewritten into a shorter factual summary.
[[/CLM_ENTRY id=1]]

Key editing rules (excerpted from the official README):

  • Only modify the block body; preserve CLM_SNAPSHOT, CLM_ENTRY, and closing tags.
  • id is a readable sequence number starting from 1; do not change IDs or reorder blocks. The extension still uses Pi’s opaque entry ID internally.
  • Deleting an editable block omits that message from subsequent projections; the initial user task is protected and does not appear in the editable area.
  • All accepted mirror edits follow a shrink-only policy: the post-edit context must be strictly shorter than the pre-edit context, otherwise it is rejected.

cleanup and Indexing

The model can call the host-provided cleanup({ blockIds: [...] }) to delete stale, duplicate, or noisy content by 1-based editable IDs. It can also use parameters like ranges: ["3-16"] or skipRoles: ["user"]. cleanup({ list: "3-16" }) performs a read-only expansion without deleting. Assistant and tool result pairs are processed cascadingly to avoid orphaned tool messages.

DSH injects <oh-my-clm-block-index> into the runtime context, controlled by the CLM_INDEX_MODE:

  • digest (default): Summarizes by turn, suitable for long sessions.
  • blocks: Lists the ID, role, and short preview of each editable block individually.

In-process, you can use /clm mode [blocks|digest|auto] for A/B switching without restarting; persisting across restarts requires setting environment variables.

DSH-Side Contract

The community discovery entry point is dsh-plugin.json in the repository, and the build entry is dist/dsh/index.js; bundle metadata is in package.json (dsh.bundle.patch) and cordis.patch.yml. DSH integrates via Cordis extension points such as agent/pre-step, session/event, systemPrompt.context(), and tools.register(); cleanup performs native replacement on the current session surface and does not rely on reading the mirror file to complete deletions.

Installation and Activation

dsh plugin is the DSH package management entry point. A profile (e.g., web or tui) must be specified during installation:

# Install from npm
dsh plugin --profile <profile> add oh-my-clm

# Install from GitHub
dsh plugin --profile <profile> add github:DevZjQx/oh-my-clm

Restart the corresponding profile after installation:

dsh --profile <profile>

Uninstallation:

dsh plugin --profile <profile> remove oh-my-clm

To pin a version, add @<version> after the package name for npm sources (e.g., oh-my-clm@0.1.12), or #<ref> after the repository for GitHub sources. The plugin runs with the permissions of the current DSH process; please review the repository source code and license before installing (if the license field is not listed separately in the documentation, refer to the repository).

Pi users can use pi install npm:oh-my-clm or pi install git:github.com/DevZjQx/oh-my-clm. This is unrelated to the DSH path discussed here and will not be expanded upon.

Typical Usage

  1. After installing and restarting the profile, start a task that generates multi-turn tool outputs; the extension will automatically refresh the mirror at session start and before requests.
  2. When history compression is needed, let the model call cleanup({ blockIds: [...] }) based on block IDs, or perform a read+write rewrite of LIVE_CTX_MAIN.md within the same host-side tool call (when shortening existing blocks, standard edits only apply to complete, non-truncated bodies).
  3. View the current mirror path, byte count, number of editable blocks, token estimation, and shrink-only policy:
/clm
/clm status

DSH also supports /clm mode to switch the index shape. Neither host provides /clm refresh; for manual full compression, Pi’s native /compact can still be used (DSH-side behavior is subject to host documentation).

Optional environment variables (explicitly mentioned in the documentation):

# Approximate target budget; when reaching about 0.75 × max(1, budget - 2048), it nudges the model to perform a cleanup or mirror edit
CLM_CONTEXT_BUDGET=32000

# DSH can override mirror display limits (default consistent with Pi: ~12000 chars per block, ~96000 chars total mirror)
CLM_MAX_BLOCK_CHARS=...
CLM_MAX_MIRROR_CHARS=...
CLM_INDEX_MODE=digest   # or blocks

Use Cases and Caveats

Suitable for: Long-session agents and tool-chain-intensive tasks where you want the model to delete outdated blocks or rewrite them into short summaries under host constraints, rather than relying entirely on external scripts to modify session files.

Boundaries (Summary from the official “Design Boundaries”):

  • The mirror is located in the system temporary directory with default permissions 0700 for directories and 0600 for files; it should not be committed to Git.
  • Display truncation only affects the preview and does not change the canonical source; if a tool result has read the full mirror, future projections will replace it with a short pointer to avoid self-replication.
  • Directly modifying the mirror outside of an agent turn will be reverted to the canonical projection on the next sync.
  • Token estimation is a provider-independent approximation (e.g., 3.5 chars/token), not an exact tokenizer; the final context window is still subject to DSH/Pi.

The DSH ecosystem adopts “everything is a plugin”; community directories like SkillHub are independent sites and have no official affiliation with DeepSeek / High-Flyer. oh-my-clm has 1 star on GitHub (subject to the directory page/repository display at the time); please evaluate maintenance activity and DSH version compatibility yourself before use (the README mentions bundle metadata behavior in the context of DSH 0.2.0-rc.2).

Conclusion

oh-my-clm implements the CLM harness’s “editable live context mirror + model self-organization” in both Pi and DSH hosts: temporary files carry protocol-based blocks, and cleanup with shrink-only edits ensure sessions can be shortened and audited. If you need an actionable “memory” layer in the Harness rather than passive truncation, you can install it into your profile using the commands above and try it out with /clm status and cleanup.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye