Introduction

DeepSeek Harness (DSH) adopts the philosophy of “everything is a plugin”. When developing large-model-based coding agents, persisting session memory and passing context are core challenges. The dsh-thread plugin aims to provide DSH with a deep session-memory solution. By capturing event streams losslessly, injecting structured state, and storing data locally, it addresses context loss or fragmented memory in agents during long-running tasks.

What It Is

zhaoyuntao-wl/dsh-plugin-thread is a deeply integrated plugin connecting the Thread ecosystem with DeepSeek Harness. It uses DSH native channels to implement end-to-end session memory management. The plugin stores event streams in an embedded SQLite database, provides deterministic retrieval (based on BM25) and structured state injection, and helps coding agents maintain contextual coherence across multi-turn interactions.

Core Features

The plugin primarily provides the following capabilities:

  • Lossless capture: Subscribes to session/event and appends the complete event stream to an embedded SQLite database, ensuring no data loss and idempotence.
  • Structured delivery and triple triggering: Injects memory into the model context through first-turn anchors (project identity, behavioral contract, state card), post-compaction re-anchoring, and per-turn boundary state increments. This design follows a deterministic logging principle and avoids generating excessive noise on every turn.
  • Native query tool: Registers the query_session_memory tool and supports file-system-style navigation commands (ls, cd, cat, grep) for retrieval. It uses BM25 for deterministic retrieval by default and does not depend on embedding models.
  • Behavioral contract skill: Registers the thread skill and injects anchors to ensure the model knows it has memory capabilities.
  • Explicit decision and preference channels: Records decisions with /thread-reg dec (--supersedes supported for chained evolution), and records preferences or lessons with /thread-reg fdb (automatically detects negative patterns such as “don’t”).
  • Wrap-up deposition and inbox: Uses closing cues to deposit in-progress goals as ToDos. /thread-cfm provides a unified view of ToDos and candidate items, supporting do (complete/promote) and cnl (cancel) operations.
  • Resource cleanup: Revokes registrations with /thread-rev, deleting decision, preference, or asset records, while handling self-healing of the goal state machine.
  • Session isolation: Supports switching session context with /thread-iso and /thread-uniso, and publishing memory rows generated during isolation with /thread-pub.
  • Optional proactive compaction: After setting THREAD_AUTO_COMPACT=1, the plugin silently compacts and re-anchors when the token-pressure threshold is triggered.

Installation and Enablement

In a DSH project, the plugin must be referenced in the bundles array of the configuration file to take effect.

  1. Install the plugin
    dsh plugin add dsh-thread
  1. Configure the Profile
    Add dsh-thread to bundles in ~/.dsh/profiles/<your-profile>/package.json:
    {
      "name": "dsh-profile-my",
      "private": true,
      "dsh": {
        "profile": {
          "bundles": [
            "@deepseek-ai/dsh-base",
            "@deepseek-ai/dsh-headless",
            "dsh-thread"
          ]
        }
      }
    }
  1. Dependencies and version
    The plugin automatically resolves the @thread-memory/core dependency. Before running, ensure the DSH version is 0.1.5-rc.1 and that SDK peers are locked to ^0.1.5-rc.1.

  2. pnpm 10 compatibility
    If the plugin fails to start under pnpm 10 with the error “Could not locate the bindings file”, rebuild better-sqlite3 in the Profile directory:

    cd ~/.dsh/profiles/<your-profile>
    pnpm rebuild better-sqlite3

Configuration Options

The plugin can be configured through environment variables or configuration items:

Configuration Default Description
budgetLines 200 Row budget for the state card
feedbackRows 50 Feedback rows referenced by the tool guard
busyRetries / busyRetryDelayMs 20 / 100 SQLite busy retry policy
compactPressureTokens 0 Token threshold for proactive compaction (0 disables it; use with THREAD_AUTO_COMPACT=1)

Commands and Usage

The plugin registers commands prefixed with /thread-, supporting command completion and direct execution.

Register Resources

# 查看列表
/thread-reg <ast\|dec\|fdb\|gol>

# 注册资产
/thread-reg ast <text>
# 注册决策(支持 --supersedes <id> 进行演化)
/thread-reg dec <text>
# 注册偏好/教训
/thread-reg fdb <text>
# 注册目标
/thread-reg gol <text>

Revoke and Cleanup

# 撤销注册(删除结构化行)
/thread-rev <ast\|dec\|fdb\|gol> <ids\|all>

# 撤销目标(放弃目标并自愈 Todo)
/thread-rev gol <ids\|all>

Session Management

# 进入隔离会话
/thread-iso

# 退出隔离会话
/thread-uniso

# 发布隔离期间产生的行
/thread-pub <ast\|dec\|fdb\|gol> <ids\|all>

State Confirmation

# 查看待办与候选列表
/thread-cfm
# do: 完成或提升候选
# cnl: 取消
# cnl all: 清空所有

Technical Details and Notes

  • Local-first and daemonless: The plugin runs entirely in-process, uses embedded SQLite storage, and requires no background services or cloud dependencies. Offline session behavior is consistent with online behavior.
  • Retrieval mechanism: By default, it does not depend on embedding models. It uses the BM25 algorithm with jieba tokenization and supports citation backtracking.
  • Honest boundaries:
    • Candidates are not generated automatically; natural-language extraction of preferences/decisions is disabled by default and relies on explicit commands.
    • Goal completion detection is conservative (≥4 non-ASCII or ≥8 pure ASCII overlap). Short English goals may be missed, so use /thread-rev gol to explicitly abandon them.
    • Decisions do not expire automatically; use --supersedes to mark outdated decisions.
  • Development probe: The package includes a batch0-probe module for contract testing during development. It is effective only when THREAD_B0_PROBE=1 is set; in production, it remains lazy by default.

Summary

dsh-thread provides a complete session-memory solution for DeepSeek Harness. With deterministic logging, structured injection, and local storage, it helps coding agents maintain memory accuracy and coherence in complex interaction scenarios. The plugin follows the MIT license and is maintained by the community.

  • Catalog Page: https://www.skillhub.cn/plugins/zhaoyuntao-wl/dsh-plugin-thread
  • Source Code: https://github.com/zhaoyuntao-wl/dsh-plugin-thread