Preface¶
In DeepSeek Harness (dsh), the tool resolution order is agent → preset → global. Preset compositions mount their own tool rows, but do not narrow the tools inherited from the global layer. Therefore, as long as computer-use drivers, browser MCPs, image providers, etc. are mounted at the host side, these capabilities will appear in every preset’s model tool catalog—including the minimal preset that only intends to expose two or three tools.
Disabling these providers is not a good approach: capabilities would be lost entirely, affecting all presets and sessions. Upstream discussion on the preset side can be found at deepseek-ai/deepseek-harness#5786. The public API provided by the Harness is the agent-scoped ctx.tools.restrict({ allow, deny }): it masks the layers inherited by that scope (global and ancestor scopes), and does not touch tools registered by the scope itself. Below we introduce the community plugin dsh-preset-tool-guard (maintainer KouzakiUmi, category admin-security), and how it connects this seam to the preset lifecycle.
What Is This¶
dsh-preset-tool-guard is a DeepSeek Harness plugin: mounted once at the host layer, it listens for agent/created, reads the presets that Agent actually composes, and calls the official ctx.tools.restrict() on that Agent’s own scope. The effect is: each preset exposes only the inherited tools it should see, while heavyweight providers remain globally mounted and need not be detached.
The npm package name is dsh-preset-tool-guard, and the published version referenced in current materials is 0.1.2 (MIT). Community directory page: SkillHub - dsh-preset-tool-guard; source code and documentation: GitHub - KouzakiUmi/dsh-preset-tool-guard.
Core Features and Behavior¶
After the plugin is mounted, the following changes occur to the model and runtime (consistent with the README):
| Aspect | Effect |
|---|---|
| Model-side tool schema (prefix per request) | Masked tools no longer appear |
| PTC-mode SDK surface | Also invisible (both projections read the same view) |
| Dispatch | Masked calls return UNKNOWN_TOOL; this is a true block, not a display-layer filter |
| Other Agents / presets | Unaffected; restrictions are scoped per scope |
| Provider itself | Still mounted; capabilities retained in allow remain available |
Key points in brief:
- Restrictions are applied on
agent.ctx(the Agent’s own scope);restrict()derives the scope from the call context and cannot run in a scope-less plain context. - Filtering snapshots at registration time. The allow list retains only names present at snapshot time; tools appearing later on the inherited layer are not automatically allowed. If you need a later-registered provider to be visible, create new Agents after it is registered.
- Even if no tools are currently excluded, allowlist matches still install masks so the fail-closed policy does not degrade into fail-open.
- The plugin listens for
tools/change, appending denials for inherited tools that are registered later and match deny / prefix / disabled-group rules; it does not rebuild the allowlist snapshot, nor add late-arriving allowlist names. - If
ToolRuntime.view()is unavailable, the plugin skips masking with an explanation, rather than misusingschemas()and causing the entirerestrict()to fail.
At load time it also scans existing Agents returned by agents.list() and applies the rules.
Installation and Activation¶
Environment requirements: Node ^22.19 or >=24 (see engines in the package); the Harness must expose ToolRuntime.restrict() and the agent/created event. The package ships its own cordis.patch.yml; installing it mounts the plugin row.
In any environment with the dsh CLI (TUI, web profile, etc.), run:
dsh plugin --profile <profile> add dsh-preset-tool-guard
Install from GitHub:
dsh plugin --profile <profile> add github:KouzakiUmi/dsh-preset-tool-guard
Install from a local directory:
dsh plugin --profile <profile> add /path/to/dsh-preset-tool-guard
Pinned version example: dsh-preset-tool-guard@0.1.2.
DSH Desktop: if dsh is not on your PATH, use the desktop app’s bundled terminal shim (the README was verified on DSH Desktop 2.0.17-next and core 0.2.0-rc.2), e.g. Windows PowerShell:
$env:ELECTRON_RUN_AS_NODE = '1'
& "C:\Program Files\DSH NEXT\DSH NEXT.exe" --expose-internals `
"C:\Program Files\DSH NEXT\resources\app\lib\desktop-cli.js" `
plugin --profile desktop add dsh-preset-tool-guard
--profile is required; the built-in dsh will not start a profile named desktop outside the Electron path.
Restart DSH after installation: the plugin is a host-side bundle, and a running process still retains the old tree. To uninstall, replace add with remove, and delete the preset-tool-guard config entry from the profile’s patch; removing only the package line leaves a dangling config block.
Configuration¶
The plugin’s bundled patch defaults to a conservative mode (dryRun: true, no allowlists). Real policies should be written into the profile’s cordis.patch.yml. The loader config for the same entry id is replaced wholesale, so you must write all fields you care about—including dryRun, otherwise the code default becomes false (enabling masking).
- id: preset-tool-guard
config:
allowlists:
minimal: [bash, pwsh, str_replace_editor]
standard: [read, write, edit, glob, grep, pwsh, skill, todo_write, web_search, memory_recall]
text: [read, write, edit, glob, grep, pwsh, grok_imagine_edit]
deny: []
denyPrefixes: []
groups: {}
disableGroups: []
skipUncomposed: true
report: true
reportFile: C:/Users/you/.dsh/logs/preset-tool-guard.log
dryRun: false
Commonly used fields (code defaults see the README table):
allowlists:{ presetId: [toolName, …] }. Matching presets retain only inherited tools in the list; other inherited tools are masked. On empty arrays or no restrictable matches, the allowlist is skipped with a warning rather than clearing the inherited surface; presets not present in the map have no allowlist and remain subject todeny/ group rules.deny/denyPrefixes: remove tools from all Agents by exact name orstartsWithprefix.groups/disableGroups: named groups and group ids to disable.skipUncomposed(defaulttrue): Agents with no composed preset skip the allowlist; deny / groups still apply.report/reportFile: write one report line per (re)application; default$DSH_HOME/logs/preset-tool-guard.log.dryRun(code defaultfalse): only measure and report, without changes; recommended to turn on first when tuning.
Typical Usage¶
- Install the plugin in the host profile and restart DSH.
- In the profile’s
cordis.patch.yml, configureallowlistsforpreset-tool-guard, listing by preset id the inherited tool names to retain; usedenyordenyPrefixesfor tools you do not want globally (e.g. thecua_driver_native__prefix in the README example). - For the first rollout, set
dryRun: true, check the report inreportFile, and confirm the masking scope before settingdryRun: false. - If a provider renames after an upgrade, names not present in the list are skipped (no error thrown), and the report will note it; you need to manually update the config or retry the allowlist snapshot on a new Agent.
Use Cases and Notes¶
Suitable for: hosts with multiple heavyweight providers mounted on the same Harness, but wanting different presets like minimal and standard to see only their designed tool sets on the model side; needing admin / security-oriented tool-surface convergence without unloading global providers.
Notes:
- The plugin runs with the current
dshprocess privileges; review the source code and LICENSE yourself before installing to confirm it meets your security policy. - SkillHub etc. are community directories with no official affiliation with DeepSeek / High-Flyer; installation commands are per the README.
- The allowlist has snapshot semantics: tools mounted after Agent creation that should be allowed do not automatically enter the whitelist; plan provider load ordering or recreate Agents.
- The reserved PTC transport name
run_codeis not written into the filter.
Conclusion¶
dsh-preset-tool-guard hooks ctx.tools.restrict() into agent/created, narrowing the inherited tools visible to each Agent per preset while keeping global providers mounted, and adds global fallbacks via deny, prefix, and group rules. For details, field descriptions, and Desktop installation, refer to the GitHub README (including README.zh.md).
- Directory page: https://www.skillhub.cn/plugins/KouzakiUmi/dsh-preset-tool-guard
- GitHub: https://github.com/KouzakiUmi/dsh-preset-tool-guard