Skip to main content
L

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-hook

README

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/recall and injects the results as prior context through agent.inject(), so a new session opens with what earlier sessions learned about that project.
  • Retain (session/event → assistant/message) — posts each assistant reply to /memories so 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:

GoalCall
Check statusaction=status
Enableaction=on
Enable with a bankaction=on, bank=yuanliu
Enable against another endpointaction=on, url=http://10.0.0.9:8888
Disableaction=off
Change bankaction=bank, bank=dsh::myproj
Change endpointaction=url, url=http://10.0.0.9:8888
Toggle recall / retainaction=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: true to 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:crypto and reads services from ctx, so it has no @deepseek-ai/* dependency.
  • /hindsight needs DSH ≥ the release that registers commands, workspaces, and the plugin config editor; the hindsight_workspace tool is the primary entry point and does not depend on composer command recognition.

License

MIT

Related plugins