Foreword¶
When running agents in DeepSeek Harness (DSH), the context window is often filled with two types of content: one is curl, wget, or the host’s built-in web_fetch / read_page writing entire page responses into the transcript; the other is when some tool call has already returned tens of thousands of lines of logs, JSON, or tables, while the model actually only needs a count, a summary, or a few excerpts. The common workaround is to manually delete messages afterwards or switch to shorter commands, but the flood has often already entered the context at the moment the call is made.
The dsh-context-toolkit introduced below (maintained by chimneyQ, categorized as admin-security in the community catalog) does one thing specifically: keep bulk output out of the conversation. It uses a routing gate before execution to reject calls that will inevitably flood, and applies output slimming after tool execution to process content that has already been returned; the raw bytes can be read back losslessly via ctk_retrieve using markers. The knowledge base is built on Node’s built-in node:sqlite (including FTS5), sandbox execution uses the interpreter already present on the machine, with no third-party runtime dependencies.
What Is This¶
In one sentence: a DSH bundle that separates “raw bytes” from “conclusions” — commands run in subprocesses, large files are analyzed in the sandbox, long materials are written into the local knowledge base, and only conclusions, excerpts, and statistics remain in the conversation.
| Pain point | Plugin approach |
|---|---|
| A command prints thousands of lines, but you only need a count | ctk_execute runs it in a subprocess and returns only the answer |
| You need statistics on a large file, not the full text in the conversation | ctk_execute_file keeps the file’s bytes in the sandbox |
| Multiple commands for one question | ctk_batch_execute — one call, per-command status |
| A page or spec needs to be queried repeatedly after one read | ctk_index into the store, ctk_search pulls excerpts on demand |
curl / wget paste the whole response into the conversation |
the routing gate rejects and points to an alternative path |
| You don’t know how much context was saved | ctk_stats accounting; the settings page has a live usage panel |
Core Capabilities¶
Tool Overview¶
| Tool | Purpose |
|---|---|
ctk_execute |
Execute code in a sandboxed subprocess (javascript / esm / typescript / shell), returning only the answer |
ctk_execute_file |
Run statistics or extraction on a file; the file’s body never enters the conversation |
ctk_batch_execute |
Multiple commands in one call, per-command status, conclusions only |
ctk_index |
Write text or files into the local FTS5 knowledge base |
ctk_search |
Multi-query retrieval; excerpts centered on match positions |
ctk_retrieve |
Read back the pre-slimming original text from [ctk_retrieve id=…] markers, byte-for-byte identical |
ctk_fetch_and_index |
Fetch a page → strip markup → store it |
ctk_purge |
Delete archived materials (requires confirm: true) |
ctk_stats |
Savings ledger: rejection count, sandbox bytes, archived bytes, call counts |
ctk_doctor |
Self-check: interpreter, scratch directory, knowledge base roundtrip |
ctk_context_report |
Current session’s context usage and composition |
Two Lines of Defense¶
Routing gate (pre-entry): reads call parameters before tool execution and rejects paths that will inevitably flood the transcript (e.g., curl / wget inside any shell, plus optional nudges for web_fetch / read_page). The master switch is the routing config item, with denyCurlWget enabled by default.
Output slimming (post-event): the gate can only inspect parameters; large outputs that have already returned are handled by tools/post-execute according to their shape — uniform JSON arrays get losslessly re-encoded as tables; tables keep the head and tail while sampling the middle steps with original line numbers preserved; grep / search-style results are folded by file, etc. When the full text is needed, use ctk_retrieve to fetch the stored original.
Configuration Essentials¶
The following default values and their meanings come from the plugin README (excerpt):
| Key | Default | Meaning |
|---|---|---|
routing |
true |
Master switch for the routing gate |
denyCurlWget |
true |
Directly block curl / wget |
bashNudgeMinCommandBytes |
4096 |
Nudge threshold for overly long shell commands (0 disables) |
maxReadBytesBeforeAsk |
51200 |
Nudge threshold for whole-file reads (0 disables) |
nudgeFetchTools |
true |
Also nudge the host’s fetch tools |
compressNudgeTokens |
120000 |
Usage warning threshold (tokens) |
searchLimit |
5 |
Number of excerpts per query for ctk_search |
snippetChars |
900 |
Character limit per excerpt |
fetchMaxBytes |
2000000 |
Single-page fetch limit |
caPemPath |
auto |
TLS trust for ctk_fetch_and_index; if a TLS inspection proxy causes UNABLE_TO_VERIFY_LEAF_SIGNATURE, a PEM can be configured |
storageDir |
empty | Knowledge base root directory; if empty, <DSH_HOME>/context-toolkit |
Each ctk_* tool can be toggled individually via tools.*; all are enabled by default. The Context Toolkit settings page can show whether the file corresponding to caPemPath exists, and can export a snapshot from the system’s root certificates (confirmation required before overwriting any existing file).
Installation and Enabling¶
Recommended to install from npm:
dsh plugin --profile desktop add dsh-context-toolkit
To install from GitHub:
dsh plugin --profile desktop add github:chimneyQ/dsh-context-toolkit
Local path (the example below is a Windows path; replace it with your checkout location):
dsh plugin --profile desktop add D:\path\to\dsh-context-toolkit
You should see dsh-context-toolkit under dsh.profile.bundles in <DSH_HOME>/profiles/desktop/package.json. To uninstall:
dsh plugin --profile desktop remove dsh-context-toolkit
The current npm package version is 0.3.12, licensed under MIT (see package.json).
Typical Usage¶
Principle: for any analysis, counting, filtering, or aggregation, prefer ctk_* — reading results into the conversation is exactly the problem this plugin exists to solve.
Count .log files and their total size in a directory:
// How many .log files, and how big in total?
await ctk_execute({
language: 'javascript',
code: `
const fs = require('fs');
const dir = process.argv[2];
let n = 0, bytes = 0;
for (const f of fs.readdirSync(dir)) {
if (!f.endsWith('.log')) continue;
n++; bytes += fs.statSync(dir + '/' + f).size;
}
console.log(n + ' files, ' + bytes + ' bytes');
`
});
Index a long document and pull passages by keyword:
await ctk_index({ path: 'D:/specs/api.md' }); // the full text stays in the store
await ctk_search({ queries: ['rate limit', 'auth'] }); // only the relevant excerpts come back
Offline self-checks (not dependent on the DSH runtime) can be run in the plugin directory via scripts from the README such as node smoke.mjs, covering contract, gate, slimming, and retrieval checks.
Applicable Scenarios and Notes¶
Who it’s for: developers who build agents on the DSH desktop profile long term, frequently run shell commands, read large files, or fetch web pages, and want the transcript to contain mostly conclusions rather than raw dumps.
Permissions and security: the plugin runs subprocesses and reads/writes the knowledge base and sandbox directories with the current dsh process permissions; the routing gate can rewrite or reject certain tool-call behaviors. Review the GitHub source code and the MIT license yourself before installing; the admin-security categorization also signals that it has policy-based interception capability, so it is not suitable for blindly enabling in sensitive production environments without understanding the configuration.
Ecosystem note: the DSH community plugin catalog is maintained on independent sites such as SkillHub, with no official affiliation with DeepSeek / High-Flyer; facts in this article are based on the repository README and package.json.
Conclusion¶
dsh-context-toolkit uses pre-entry rejection + post-event slimming + a local FTS knowledge base + retrievable original text to leave context for reasoning rather than log stacking. If you are often dragged down by curl output or giant tool results in the Harness, install it with the commands above, then run ctk_doctor / ctk_stats to verify the environment and see the savings.