DSH-Lossless-Context: Traceable DSH Context Compression and Retrieval

Preface

When running long sessions in DeepSeek Harness (DSH), the context window will eventually fill up. The host’s native compaction can delete or fold old content to free up tokens, but agents often need to return to “what the original text said at the time”—for example, the full output of a specific tool call or the basis for a decision. If compression leaves only a summary that cannot be cross-referenced with source events, subsequent retrieval and auditing become difficult.

Lossless Context (repo Kerberos255/dsh-lossless-context) is a hierarchical context compression and retrieval backend for DSH: it leverages native compaction transactions without replacing or deleting source session logs; before successful submission, it organizes bounded event groups into a traceable hierarchical summary DAG, and exposes session tools for searching, viewing the DAG, and expanding the original text. Maintained by Kerberos255, it is classified as a model-inference capability; the plugin is MIT-licensed, and the current package version is 0.1.31 (subject to the repo’s package.json).

What is this

In one sentence: Perform hierarchical summarization and local searchable indexing while preserving DSH’s native session records, with optional verified DM session rotation.

The data flow (consistent with the README) is as follows:

Native session events
  → native compaction selection
  → bounded summary leaves → merged summary DAG
  → native commit (only on success)
  → searchable index with references to source event IDs

The current session retains native records; retrieval and expansion resolve back to original source event IDs. Model and provider limits and existing policies control thresholds; if model metadata is unavailable, it safely reports an error rather than fabricating a budget.

Core Features

Native compaction without losing source logs

The plugin uses DSH’s native compaction transactions and will not replace or delete source session logs. Invalid, cancelled, oversized, or truncated summaries will not be committed; if multi-stage compression fails, no incomplete checkpoints are published; on retry or restart, fragments are reused only when the source content, model, and summary settings are consistent.

Hierarchical summaries and local indexing

It summarizes bounded, tool-call-safe event groups to form a hierarchical source DAG. Derivative indexes are stored in the DSH data directory and are not a second copy of the full conversation history.

The default leaf source input chunk size is 24,000 tokens (referring to input chunking, not the completion limit). Successful and complete leaves and condensed summaries are cached in a local SQLite derivative index for up to 7 days; limited to 128 entries per session and 512 globally, with a 128 KiB limit per entry. The default timeout for a single summarizer request is 240 seconds, allowing slower but legitimate merged summaries to complete.

Session tool lcm_recall

It exposes a session-level model tool lcm_recall, supporting:

  • action: 'search' (default): Retrieval
  • action: 'describe': View the summary DAG
  • action: 'expand': Expand raw source by sequence, DAG node, or query

Agents can pull back supporting original text as needed within the compressed context.

Stress and idle maintenance

Default pressure threshold checks schedule idle compaction after the turn ends; active turns are only compacted when nearing pressure or when the provider confirms a context overflow. Both modes share the same retainRatio / retainTokens budget (including model-specific policies); the threshold (e.g., 0.5) controls when to compact, not how much recent text to retain.

The plugin bundles an MIT-licensed native helper that supplements the compactNow safe path (RC.2) with a retained-tail parameter, while other idle maintenance, full tool-pair boundaries, persistent transactions, cancellation, and checkpoint refresh behaviors remain aligned with the native implementation; when upgrading DSH, refer to native/SOURCE.md again.

It can pre-generate reusable summary leaves during the idle maintenance phase without committing compaction. Transfer errors and truncated summaries have bounded retries respectively; timeout and output budgets can be configured independently.

Optional: DM rotation after Dream & Memory

Optionally rotate eligible, owner-verified Discord / Feishu DM sessions after a verified Dream & Memory handoff is completed; recent rotation failures will back off rather than retry on every idle turn. Normal desktop / group chat / unverified sessions are not silently migrated.

Editable compression instructions

Leaves and merged summaries can be attached with customizable default quality guidelines (emphasizing project decisions, exact paths and config names, validation evidence, task status changes, etc.). The settings page provides a Restore default button. The guidelines supplement the native compaction protocol; tool pairing, source retention, cancellation, and full transaction checks remain unchanged. Modifying the summary policy will invalidate expired reusable leaves.

Optional diagnostics

It can send privacy-limited operational and failure metadata (event types, status, fixed error codes, duration) to dsh-plugin-diagnostics; it does not include conversation content or credentials. The diagnostics plugin is optional and does not change host dependencies.

Installation and Activation

The host requires compatible DSH, native session, token-meter, and compaction services; peer dependencies are listed in the repo’s package.json.

Installation command (from README):

dsh plugin --profile desktop add github:Kerberos255/dsh-lossless-context

After installation:

  1. Open Settings → Plugins → Lossless Context and enable the backend.
  2. On the agent preset that needs to use this backend, select the compaction backend dsh-lossless-context/agent.
  3. Installing the settings plugin alone does not guarantee that every preset will use this backend; a restart is required after modifying plugin code or preset composition.

The plugin runs with the permissions of the current DSH process; please review the source code and MIT license before installation.

Typical Usage

In-session retrieval after enabling the backend

After a successful compression commit, the index references source event IDs. The agent operates in-session via lcm_recall:

  • Default search: Find relevant content in summaries and indexes.
  • describe: View the current summary DAG structure.
  • expand: Expand corresponding raw source by sequence, DAG node, or query.

Specific parameter shapes are subject to the plugin implementation and DSH tool protocol; policy and regression tests can be run via npm test in the repo root (portable policy tests); actual compression and summary quality still require an active model and DSH host. See the repo’s config.example.json for example configuration.

Use Cases and Notes

Who it is for: Developers with long-running DSH agent sessions who need to trace original text and tool outputs after compression, and wish to adjust headroom, target summary length, and output budget based on the currently selected model.

Security and Storage: Only derivative indexes are stored; automatic DM rotation requires a verified owner / workspace binding and completed Dream evidence. Successful unit tests cannot replace online model compaction testing.

Ecosystem Note: The DSH community plugin catalog is hosted on an independent site (e.g., the SkillHub directory page) and has no official affiliation with DeepSeek / High-Flyer; please refer to the GitHub repo for installation and review.

Conclusion

Lossless Context bridges DSH’s native compaction with a hierarchical, searchable summary DAG: source sessions remain, and agents use lcm_recall to search, describe, or expand the original text; idle and stress policies, failure retries, and optional DM rotation all have clear boundaries defined in the README.

  • Directory page: https://www.skillhub.cn/plugins/Kerberos255/dsh-lossless-context
  • Source code and documentation: https://github.com/Kerberos255/dsh-lossless-context
羽毛球分组比赛记分
小程序二维码

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

Xiaoye