dsh-hindsight-hook
lynn901/dsh-hindsight-hook
Scopes Hindsight long-term memory per DeepSeek Harness workspace, recalling context on session start and retaining assistant replies.
Install
dsh plugin --profile web add github:lynn901/dsh-hindsight-hookREADME
Hindsight workspace memory hook
English | 中文
A DeepSeek Harness Host plugin that scopes Vectorize Hindsight long-term memory to DSH workspaces you explicitly enable. Sessions in other workspaces are untouched — no recall, no retain, no network calls.
Two hooks run for an enabled workspace:
- Recall (
agent/created) — queries Hindsight/memories/recalland injects the results as prior context throughagent.inject(), so a new session opens with what earlier sessions learned about that project. - Retain (
session/event→assistant/message) — posts each assistant reply to/memoriesso future sessions can recall it. Fire-and-forget; it never blocks the turn.
Install
dsh plugin add dsh-hindsight-hook
Or from a checkout: dsh plugin add ./path/to/dsh-hindsight-hook.
Requires a reachable Hindsight REST API. The plugin defaults to http://127.0.0.1:8888 and every workspace can point at a different instance.
Enabling a workspace
Open a session inside the workspace and ask the agent — it calls the hindsight_workspace tool:
| Goal | Call |
|---|---|
| Check status | action=status |
| Enable | action=on |
| Enable with a bank | action=on, bank=yuanliu |
| Enable against another endpoint | action=on, url=http://10.0.0.9:8888 |
| Disable | action=off |
| Change bank | action=bank, bank=dsh::myproj |
| Change endpoint | action=url, url=http://10.0.0.9:8888 |
| Toggle recall / retain | action=recall|retain, enabled=… |
The /hindsight slash command offers the same operations. Both resolve the session's workspace through workspaceRegistry.resolveByPath(cwd), so the session must live under a registered workspace directory; configuration is persisted to the plugin's config.workspaces and applies to new sessions.
Configuration
hindsightUrl: http://127.0.0.1:8888 # default endpoint; a workspace `url` overrides it
bankId: dsh::{name} # {name}=cwd basename, {cwd}=full path
workspaces: {} # written by the tool, keyed by workspace path
# { enabled, url?, bankId?, recall?, retain? }
recall:
enabled: true
budget: low # low | mid | high
timeoutMs: 60000
maxResults: 8
factCharLimit: 320
rootOnly: true
blockOnStart: false # background recall; the session starts immediately
retain:
enabled: true
async: true # enqueue; never blocks the turn
minChars: 80
maxChars: 8000
rootOnly: true
url values accept a missing scheme (defaults to http://) and an unparseable address is rejected without being written.
Requirements and limits
- Recall works out of the box — it uses Hindsight's local embedding and reranker models, no LLM key needed. On CPU-only hosts a recall can take tens of seconds; the default is therefore non-blocking, and the recalled context arrives at the next step boundary (set
recall.blockOnStart: trueto wait for it before the first turn). - Retain's fact extraction needs a valid Hindsight LLM key. With an expired key, Hindsight still accepts the enqueue (
success: true) but the background extraction fails and nothing is stored. That is a Hindsight-side configuration issue; the plugin needs no change. - The plugin imports only
node:cryptoand reads services fromctx, so it has no@deepseek-ai/*dependency. /hindsightneeds DSH ≥ the release that registers commands, workspaces, and the plugin config editor; thehindsight_workspacetool is the primary entry point and does not depend on composer command recognition.
License
MIT