Introduction¶
In DSH (DeepSeek Harness), developers often face a dilemma between cost and quality: every time a message is sent, the complete context of the current conversation must be resent; starting a new session leaves the model unaware of the decisions made in the previous session. Thus, you either have to re-explain the background or paste the entire context block, in which case you pay for redundant input tokens. The william20100221/dsh-context-graph introduced below is a plugin in this direction. It indexes the decisions made in a session into a small topic graph. Subsequent sessions only need to append a few lines of directional content, and the model retrieves the original text by ID only when it confirms it needs details.
What is it¶
dsh-context-graph is a plugin submitted to the community directory by maintainer William20100221, categorized as “Memory,” currently holding 1 star on GitHub. It targets the DSH plugin ecosystem: DSH’s philosophy is “Everything is a plugin”; sessions, memory, and tools are mounted on the current process as plugins. This plugin belongs to the category that provides long-term memory for chat.
It aims to solve the problem of duplicate context mentioned above: instead of relying on summary compression, it stores “things that have already been decided” by topic. Other sessions only see a few lines of prompts and retrieve the original text if necessary.
Core Features¶
The plugin is enabled for memory by default. It indexes every 4 human turns in each session, writing decided items in the session into a graph composed of topics, along with the original messages. Indexing falls into the workspace’s .context-graph/chats/<chat>/ directory, containing the graph for that session, the verbatim original text, and a meta.json recording the title, date, and flags.
For other sessions in the same workspace, the plugin appends a few lines of pointer content after the message, for example:
[context-graph] Related past context from yesterday (by chat). Call recall(id) for the verbatim source.
- c3n12 builder timeout: builderMaxTokens raised to 8192 after the 524s (2026-11-01)
- c3n4 publish flow: npm version patch, npm publish (2FA), git push --follow-tags (2026-11-01)
These lines are just pointers. When the summary is not precise enough, the model calls recall("c3n12") to retrieve the verbatim original text instead of pre-filling the entire history into the context. The plugin’s design principle is: add only a few lines per message, retrieve original text on demand, saving input tokens without sacrificing quality.
The memory switch has two levels: turn off the plugin on the Plugins page, and no session will be indexed nor will any content be injected; to stop only a specific session, execute /context-graph off within that session. The directory remains, and you can resume with on from the breakpoint.
Installation and Activation¶
There are two official installation methods, both written in the project README.
GUI method: Select Add plugin on the Plugins page, use the official npm registry, type dsh-context-graph, and completely restart the application after installation (new slash commands need a restart to be used).
Command line method, for desktop app using the desktop profile:
dsh plugin --profile desktop add dsh-context-graph
After installation, chat normally; the plugin will index on its own rhythm every 4 turns. To index immediately once, type /context-graph, select build from the menu.
Command Set¶
All commands are /context-graph <word>: type /context-graph first to select from the menu, then type the keyword. Results appear in DSH’s own command card; the first line summary can be expanded for details. Without a keyword, it is equivalent to stats.
Common commands:
on— Restore memory for the current session, index once, then every 4 human turns. Each indexing requires a small auxiliary model call, defaulting to the session’s own model route.off— Stop indexing and injection for the current session only; the graph directory remains on disk.share/unshare— Sessions are shared with other sessions in the same workspace by default.unsharemakes it private,sharereverts. Sharing does not copy or merge; the graph remains in respective directories, and topic IDs carry session numbers (e.g.,c3n12), allowing hits to trace the source.stats— Default command. The first line gives the memory switch, current session topic count, shared status, visible shared session count, and waiting index turns; the body gives the version, memory directory, and since application startup: build count and tokens consumed, injection block count and volume, recall count, and splits the main session’s input into uncached, cache-read, cache-write three parts and gives cache hit rate.build— Index the current session immediately, not waiting for the next 4-turn node. Memory must be on. If the model returns unreadable output, the original output is saved inlast-builder-output.txtin the session directory, and the card explains the reason.map— List all indexed sessions in the workspace, newest to oldest, including session ID, start date, title, topic count, and flags (this chat,memory on,shared/private), and attach the topic with the highest association and its ID for each session. This is the text form of the graph; the visualization page is still in planning.find <words>— Search shared sessions using the same matcher as the plugin runtime; you can directly see the content the model will see.
Matching and Backtracking Mechanism¶
Matching is at the lexical level and does not perform semantic rewriting. Messages are split into words, identifiers (e.g., clear_conversation produces both clear and conversation), and Chinese character bigrams. Topic labels and aliases have doubled weight, gist weight is single, highly associated topics get a small bonus; only when a tag or alias hits is the topic counted. It returns at most 5 hits; when a hit is clearly leading and the source is short, it directly attaches the verbatim original text, saving one recall round trip. Updated decisions point to replacements via the supersedes edge, and when an old decision is hit, the new decision is displayed.
Time is the first layer of filtering. When a time word appears in the message, search within that time period first; if unsuccessful, expand the range:
| Input | Priority Search Scope |
|---|---|
yesterday、昨天 |
Active sessions yesterday |
3 days ago、3天前 |
That day |
last week、上周 / this week、本周 |
Monday to Monday |
last month、上个月 |
That natural month |
2026-11-01、11月1日 |
That day |
If there is no hit in the time slice or globally, the plugin falls back to listing sessions in that time period to guarantee that questions like “what did we do yesterday” still have an available answer.
Backtracking IDs look like c3n12, i.e., Session 3, Topic 12, returning the verbatim original text corresponding to that topic.
A concrete comparison: first settle a flow in one session, then open a new session in the same workspace to ask a question. The plugin will first hit the topic with a few lines of prompts, and the model will recall to get the original text only when it judges the summary is not precise enough.
Use Cases and Notes¶
Suitable for DSH users who frequently switch between multiple sessions and need new sessions to quickly connect with old conclusions, especially when multiple parallel tasks are open in the workspace simultaneously and one does not want to carry the full history every time. The cache hit rate in stats can serve as a reference for judging the benefit: a high hit rate indicates that memory is saving input; otherwise, check if the topic count and sharing scope are reasonable.
A few points need attention. The plugin runs with the permissions of the current DSH process. Before installation, you should check the source code and license (this project is MIT) and ensure the read/write scope of the .context-graph/ directory meets expectations. Indexing relies on auxiliary model calls and will consume a small amount of tokens, defaulting to every 4 turns. Sharing is on by default. It is recommended to execute unshare to make sessions with sensitive conclusions private.
Conclusion¶
The value of dsh-context-graph lies in splitting “whether to bring history” into two steps: by default, only a few lines of direction are given, and the original text is retrieved by ID when needed. It reduces the input overhead brought by duplicate context while not sacrificing completeness via summaries. See the directory page at https://www.skillhub.cn/plugins/William20100221/dsh-context-graph, and source code at https://github.com/William20100221/dsh-context-graph.