dsh-classic-tools
Web search for local models and help for small context windows, for DeepSeek Harness (DSH):
- a Web: on / off chip next to the message box, with web search through your local Ollama;
- a tool budget and a scratchpad that keep small-context models (about 49k tokens or less) on track;
- two light modes, Ultralight and Advanced thinking.
Maintenance: best-effort. Issues may go unanswered; forks are welcome.
What it adds
Web chip and /web
/web on | off | toggle | status, or click the Web chip in the message box. One switch for every conversation and every model, applied from the next message. The state is kept in<DSH_HOME>/web-toggle.json. Web starts OFF until you turn it on.- OFF: the web tools are hidden from the model, so it never calls a dead tool.
- ON:
- DSH itself searches the web for each new message of yours (not left to the model's choice) and adds the results before the model answers. Greetings, panel passages and questions about your own notes ("my notes", "in my Logseq") are not searched.
- Short research rules are added to the system prompt: answer from pages read, mark single-source facts "(unconfirmed)", end with a Sources section.
- If the answer has no Sources section, the model is sent back once to add it.
web_searchandweb_fetchgo through Ollama.web_fetchis replaced byweb_read(below).
web_read
DSH's web_fetch returns the start of a page. web_read(url, question?, start?) instead cleans the
page (CSS and script leftovers, menus, repeated paragraphs, link targets), saves it in
<DSH_HOME>/cache/web, splits it at headings, ranks the passages against the question with
BM25 (keyword scoring, no model) and returns the best ones, about 4000 characters, in page order.
The model can read other parts with another question or start=p7. A saved page is reused for 24 h
and deleted after 3 days.
Tool budget
On an agent whose context window is 49152 tokens or less (maxContextWindow), each family of tools
stays hidden until your messages mention it, and then stays available for the conversation. Larger
models keep every tool. A family is { id, tools: [tool names], words: "regular expression" }. The
defaults name the tools of the author's other plugins (Zotero, Logseq, documents, memory, tasks...);
tools that are not installed are skipped. Replace them in cordis.patch.yml:
- id: tool-budget
name: 'dsh-classic-tools/tool-budget'
config:
maxContextWindow: 49152
families:
- id: wiki
words: 'wiki|confluence'
tools: [wiki_search, wiki_page]
Scratchpad
For the same small-context models: tools step_done(step, learned), scratch_note(text),
scratch_read(name?). Notes are kept in <DSH_HOME>/scratch/<conversation>/ (state.md ledger,
steps/NN.md, notes.md, raw/ = full text of folded outputs, synthese.md = final answer). After
a step_done, long tool outputs (over 600 characters) are folded at the next step to a short head and
a pointer, the same replay-safe way as DSH's own tool-result pruner (the original stays in the
session log). The protocol and the ledger are re-sent with every request, so they survive
compaction. If you ask for the results in a folder ("save it in ~/reports"), a step that says it
wrote elsewhere is refused. Folders untouched for 7 days are removed at startup. Larger models do
not see these tools. The idea follows AgentFold and Context-Folding (2025), MemGPT's core memory and
Anthropic's memory tool.
Ultralight and Advanced thinking
Two agent modes with the smallest possible prompt for small models: no shell, no file changes, web tools only while the Web chip is ON. Ultralight answers concisely; Advanced thinking asks for step-by-step reasoning with self-checking (set Effort to "high" in the model menu).
The interface is in English, and in French when DSH's language is French. To translate the chip, add
a table next to en and fr at the top of client.js.
Install
dsh plugin --profile web add github:MathieuPortmann/dsh-classic-tools
Restart the profile afterwards. Requires Node ^22.19.0 || >=24 and DSH >=0.2.0-rc.2 <0.3.0 (see
Compatibility), and an Ollama that can answer web search and fetch requests (see
Permissions). Once the package is on npm,
dsh plugin --profile web add dsh-classic-tools works too.
Configuration
Everything has a default. Edit the rows in cordis.patch.yml (or your profile) to change:
| Row | Option | Default | Meaning |
|---|---|---|---|
web-toggle |
skipSkills |
[] |
slash commands (names without /) that work only on your own text: a message using one gets no automatic search, for example [summarize, translate] |
tool-budget |
maxContextWindow |
49152 |
agents with a window up to this size get the tool budget |
tool-budget |
families |
see above | the hidden tool families |
scratchpad |
maxContextWindow |
49152 |
agents with a window up to this size get the scratchpad |
scratchpad |
foldMinChars, foldHeadChars, ledgerMaxChars, nudgeAfterCalls, keepDays, dataDir |
600, 240, 1600, 6, 7, <DSH_HOME>/scratch |
folding and ledger sizes, reminder after N calls without step_done, days before cleanup, folder |
Environment: OLLAMA_HOST (default http://127.0.0.1:11434), DSH_HOME (default ~/.dsh).
How it works
lib/web-toggle.js(host side) registers the Ollama providers,/web, theweb_readtool, the research rules and the hooks; its pure rules are inlib/web-rules.js(search query, Sources detection, turn state).lib/web-page.jsis theweb_readengine: cleaning, passages, BM25, cache. Pure JavaScript, no dependency. It is a port of native code; the port was compared with that code on about 140,000 generated, fixture and real-page cases (cleaned text, chosen passages and cache files) with identical results.lib/tool-budget.js,lib/scratchpad.jsandlib/scratch-core.js(pure functions) hold the small-context helpers.client.js(page side) draws the chip. It reads the state from the description of the/webcommand ("... - currently ON"), so showing the state leaves no line in the conversation (a click runs/web onor/web off, which shows one short line).cordis.patch.ymladds the rows, the two modes and thewebprovider choice (searchProvider: ollama,fetchProvider: ollama). Removing the bundle removes all of it.
Compatibility
| Component | Supported |
|---|---|
| Node.js | ^22.19.0 || >=24.0.0 (engines.node) |
| DSH | >=0.2.0-rc.2 <0.3.0; declared as optional peerDependencies on @deepseek-ai/dsh-llm, @deepseek-ai/dsh-tools and zod, the only packages loaded from the DSH installation |
| Platform | Linux (tested); pure JavaScript, no native addon |
| Ollama | a version that serves /api/experimental/web_search and /api/experimental/web_fetch (experimental endpoints that may change) |
Tested with DSH 0.2.0-rc.2 on Node 22.23 (see Verification).
Permissions and external services
Everything the plugin can touch, and what happens when it fails:
| Capability | Where | Used for | If it fails |
|---|---|---|---|
| Network | lib/web-toggle.js (fetch) |
POST to your Ollama (OLLAMA_HOST, default 127.0.0.1:11434): /api/experimental/web_search (the search query) and /api/experimental/web_fetch (a page URL). Ollama's web search and fetch are served through ollama.com (see Ollama's documentation), so your search queries and the URLs the model reads leave your computer through Ollama; the plugin sends nothing anywhere else, and only while Web is ON |
web search returns an error to the model; the automatic search puts a short "search failed" note in the context |
| Files | lib/web-toggle.js, lib/web-page.js, lib/scratchpad.js, lib/scratch-core.js |
reads and writes <DSH_HOME>/web-toggle.json (the switch; watched for changes), <DSH_HOME>/cache/web/*.md (pages read by web_read; pruned after 3 days), <DSH_HOME>/scratch/<conversation>/ (scratchpad; cleaned after 7 days). No other file |
the switch reads as OFF; a page is not cached; scratchpad tools return an error |
| Commands | none | no child process, no shell | n/a |
| Dynamic module loading | lib/web-toggle.js, lib/scratchpad.js (importFromDsh) |
loads zod, @deepseek-ai/dsh-llm and @deepseek-ai/dsh-tools from the DSH installation that runs the plugin (a synchronous require of an ES module fails on Node 22). Nothing is downloaded and no code is evaluated from text (eval / new Function are not used) |
the plugin fails to load |
| Tools for the model | web_read; step_done, scratch_note, scratch_read |
see above. web_read works only on http(s) URLs and says it is unavailable while Web is OFF |
an error text is returned |
| Command | /web |
the switch | usage error |
| Hooks | agent/inbox/claimed, agent/pre-step, agent/turn-stopping, tools/pre-execute |
hide or show tools, add the automatic search results and the Sources reminder, fold old tool outputs, save the final answer | each hook swallows its own errors so a turn is never blocked |
| Session log | lib/scratchpad.js |
the scratchpad folds a long tool result by appending a compaction/prune event and a replacement tool/result event (nothing is deleted; the original stays in the log) |
the output stays unfolded |
| Interface | client.js |
one chip in the message box; registers a French dictionary and language entry with DSH's locale service | no chip |
Verification
Checked on a disposable profile (DSH_HOME pointing at a temporary folder, so the real profile is
never touched):
npm pack
dsh plugin --profile t add file:$PWD/dsh-classic-tools-0.1.0.tgz # install
dsh t --port 3095 --no-open # start: rows load, no error
dsh plugin --profile t remove dsh-classic-tools # uninstall
npm test runs 23 standalone tests (the web_read engine, the Web rules, the tool budget, the
scratchpad core and the imposed-folder rule) with no DSH installation needed.
Develop
npm test
License
MIT
No comments yet. Be the first to write one.