Preface

Running long sessions in DeepSeek Harness (DSH) presents two common headaches: first, limited context windows cause early conclusions to be “forgotten” once they are pushed out of the window; second, changing sessions makes it hard to carry over previously noted key points. A common workaround is stuffing summaries into the system prompt, but this only affects the auxiliary prompt block, while the real conversation history grows as-is, and token usage keeps rising.

The dsh-plugin-context-manager introduced below addresses these two points: automatically recording every turn of dialogue, injecting memory and cross-session pinned notes in priority order into every model request, and directly collapsing the real conversation history visible to the model to reduce token usage.

What is this

dsh-plugin-context-manager is a custom plugin for DeepSeek Harness maintained by luxiwusuobuneng. The README title is written as dsh-context-manager (Context Manager Plugin) and uses the MIT license. One-sentence positioning: automatically record every turn of dialogue, inject memory and cross-session pinned notes by priority, and collapse real conversation history to save tokens; all data is persisted to disk, ensuring persistence and safety after restarts.

The repository is split into three packages, each managing a layer:

Package Layer Responsibilities
dsh-context-manager-service-luxi Host Persistent storage, global recording, Remote API, and the root plane agent/pre-step listener: executes queued history folding, injects records and custom text into the real message stream
dsh-context-manager-agent-luxi Agent preset layer Only keeps fallback injection: when injectIntoMessages: false, injects records into a system-prompt snapshot. Record logic has been retired (globally handled by the server starting 2026-08-17)
dsh-context-manager-ui-luxi Web layer Browser UI: “Context” button in the bottom right of the input box and management window

Core Features

Automatic Recording and Priority Injection

Every turn of dialogue is automatically recorded as a record, stored by priority: index 0 is most important, injected by taking the first N records in this order. With summarize: true enabled, every turn swap asynchronously calls the current default model router to distill “summary/description” lines; failure automatically falls back to truncation.

Records have a limit: when exceeding maxRecordsPerSession, delete the oldest non-pinned record by createdAt. Pinned records are not affected by the limit. The scope is the root session of all presets; sub-agents and workflow sub-sessions are not recorded to avoid pollution and token waste.

Pinned Notes and Custom Text Enter Real Message Stream

Pinned (⭐) records and custom text in “Injection Settings” are injected as a real message before every model request, implemented by the server modifying messages in pre-step (injectIntoMessages), rather than just putting them in the auxiliary prompt block.

Real Conversation View and Manual Folding

conversationList lists every message the model actually sees, including role, text, token estimation, total usage, and also summary nodes left by previous folds.

foldRange selects a message range to queue in the “Real Conversation”. The next time dialogue starts, the server executes compaction.compactRegion() inside agent/pre-step, truly folding old text into a summary to reduce token usage. Folding must be executed within the turn, so it takes effect “after the next message”; foldStatus can query the queue and execution status.

Browser Management Window

After installation, a “Context” button appears in the bottom right of the input box on the web page. Clicking it opens the management window, containing tabs for records, real conversation, injection settings, etc. It supports search, edit, cross-session pinning, drag-and-drop sorting, export, and clear.

Runtime Adjustable and Persistent

Items like the number of injections (maxInjected), character budget (maxInjectionChars, maxCharsPerRecord), and record limit (maxRecordsPerSession) can be overridden and persisted via setSettings at runtime without needing to change configuration and restart. Records, injection, queued folding, and folding audit are all persisted to disk, working normally after restarts.

Installation and Enablement

To be clear first: this is a manual multi-step installation, not a standard one-click installation. The process involves copying the three package directories first, manually wiring cordis.patch.yml, and finally restarting DSH.

Step 1, copy package files. Copy the three folders dsh-context-manager-service-luxi, dsh-context-manager-agent-luxi, dsh-context-manager-ui-luxi completely to C:\Users\YourUsername\.dsh\profiles\node_modules\; or execute the following command in the repository root directory to let the script copy automatically:

powershell -NoProfile -ExecutionPolicy Bypass -File .\install.ps1

install.ps1 is only responsible for copying the three packages and does not modify cordis.patch.yml; wiring needs to be done manually. If the output is [FAIL], it means the source directory for the corresponding package is missing package.json, check the directory arrangement first.

Step 2, wiring. Edit %USERPROFILE%\.dsh\profiles\web\cordis.patch.yml, appending three lines to the insert list. If the file already contains content starting with - insert:, merge the three lines into it, do not repeat keys:

- insert:
    - id: compaction-passive
      name: '@deepseek-ai/dsh-compaction-basic'
      config:
        auto: false
    - id: context-manager
      name: 'dsh-context-manager-service-luxi'
      config:
        maxRecordsPerSession: 200
        injectIntoMessages: true
        maxInjectionChars: 800
        maxInjected: 5
        maxGlobalInjected: 3
        maxCharsPerRecord: 200
        summarize: true
        maxSummaryChars: 400
        maxDescriptionChars: 200
        summarizeTimeoutMs: 20000
        summarizeMaxInputChars: 6000
        summarizeMaxOutputTokens: 300
    - id: context-manager-ui
      name: 'dsh-context-manager-ui-luxi'

The values above are example defaults: maxInjected takes the first few records for injection each time, maxRecordsPerSession is the single-session record limit, summarize related items control the length and timeout of the LLM summary, and can be adjusted as needed.

There are three constraints for wiring:

  1. The compaction-passive line is a dependency for the browser folding button. Missing it only affects folding functionality, not recording.
  2. The UI line must be attached to the web composition (loader entry); attaching it to the agent preset layer will not be scanned by clientModules, resulting in a 404 bundle.
  3. The dsh-context-manager-agent-luxi line is optional, only providing fallback injection when injectIntoMessages: false; not hanging it does not affect functionality.

Step 3, verification. After the above steps, completely restart DSH (Service/Agent loads when the process starts, hot reload is invalid), open the web version dialogue interface. If a “Context” button appears in the bottom right of the input box and clicking it opens the management window, the installation is successful.

Subsequent upgrades: if only changing code inside the package, repeat Step 1 and Step 3. Changes to Service require restarting DSH; pure UI (client.js) changes only require refreshing the browser page.

Typical Usage

Folding a Segment of Real History

In the management window’s “Real Conversation” page, select a message range to execute foldRange; folding takes effect inside agent/pre-step during the next message. Programmatic calls go through the Remote API, for example:

connection.rpc.call('/api', 'contextManager/foldRange', { args: { sessionId, start, end } });
connection.rpc.call('/api', 'contextManager/foldStatus', { args: { sessionId } });

The first line queues a folding request, and the second line queries its execution status.

Remote API

The browser calls the Remote API via connection.rpc.call('/api', 'contextManager/<method>', { args }). Methods include: list, count, record, remove, reorder, update, setGlobal, clear, listGlobal, compact, conversationList, foldRange, foldStatus, setInjectionText, getInjectionText, getSettings, setSettings, clearAll. The runtime override of setSettings persists and is not lost on restart.

Applicable Scenarios and Notes

Who is it suitable for:

  1. Long sessions running for a long time where early info is pushed out of the window, wanting the old text to truly leave the context, not just adding a summary beside it.
  2. Need to carry fixed agreements or notes across sessions, using pinned records to inject into all sessions.
  3. Need to verify the model’s actual input: first use conversationList to see the role, text, and token usage of each message, then decide on folding and injection.

Notes:

  1. Installation is a manual multi-step process; install.ps1 does not handle wiring; cordis.patch.yml must be modified manually.
  2. The folding button depends on the compaction-passive line in the root plane; missing it only affects folding, not recording.
  3. The record logic of dsh-context-manager-agent-luxi has been retired (globally handled by the server starting 2026-08-17), only keeping fallback injection.
  4. Folding must be executed within the turn, taking effect after the next message, not immediately.
  5. The plugin runs with the permissions of the current DSH process; it is recommended to read the source code thoroughly before installation to confirm the MIT license and code behavior meet your usage requirements.

Summary

dsh-plugin-context-manager puts recording, injection, folding, and viewing into a single plugin. Injection and folding both act on the real message stream, and persistence plus runtime adjustability reduces the need for a restart in daily use. The installation steps are more than a one-click install, but every step’s result can be verified, making it suitable for developers who need to maintain DSH session context for a long time.

  • Directory page: https://www.skillhub.cn/plugins/luxiwusuobuneng/dsh-plugin-context-manager
  • GitHub: https://github.com/luxiwusuobuneng/dsh-plugin-context-manager

The directory page comes from an independent community plugin directory and has no official affiliation with DeepSeek or High-Flyer; under the DSH philosophy of “everything is a plugin,” such third-party plugins are a supplement to the ecosystem.