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/eventand 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_memorytool 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
threadskill and injects anchors to ensure the model knows it has memory capabilities. - Explicit decision and preference channels: Records decisions with
/thread-reg dec(--supersedessupported 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-cfmprovides a unified view of ToDos and candidate items, supportingdo(complete/promote) andcnl(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-isoand/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.
- Install the plugin
dsh plugin add dsh-thread
- Configure the Profile
Adddsh-threadtobundlesin~/.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"
]
}
}
}
-
Dependencies and version
The plugin automatically resolves the@thread-memory/coredependency. Before running, ensure the DSH version is 0.1.5-rc.1 and that SDK peers are locked to^0.1.5-rc.1. -
pnpm 10 compatibility
If the plugin fails to start under pnpm 10 with the error “Could not locate the bindings file”, rebuildbetter-sqlite3in 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 golto explicitly abandon them. - Decisions do not expire automatically; use
--supersedesto mark outdated decisions.
- Development probe: The package includes a
batch0-probemodule for contract testing during development. It is effective only whenTHREAD_B0_PROBE=1is 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