@little_monkey/dsh-preset-tool-gate
v0.3.0
Published
Hides host-registered tools from agents whose preset declares only its own tools.
Maintainers
Readme
@little_monkey/dsh-preset-tool-gate
Hides Host-registered tools from agents whose agent preset declares only its own tools.
Why
Tools registered on the Host context (MCP clients, host tool rows, experimental bundles) live in the global tool layer, and every Agent inherits them no matter which preset it mounted. A preset can only drop the tools its own plugin list fails to declare. The shipped minimal preset, for example, declares a fixed persona, read_image and a persistent shell, yet its first model request carried 71 tools — roughly 66 KB of JSON schema per request — because every host-registered tool was still visible.
What it does
The plugin is mounted on the Host plane. For every live Agent it reads the Agent's own live preset (agentPresets.presetForSession, falling back to the session header):
- preset in
isolatedPresets: it reads the names currently registered in the global tool layer and appliesagent.ctx.tools.restrict({ deny })over them; - any other preset: it lifts the mask.
Preset-owned tools are registered in the Agent's parent (preset) scope, not in the global layer, so they never appear in the deny list and stay visible. The plugin deliberately does not use allow: [], which would mask preset tools too.
Masks are re-aligned on agent/created, agent/disposed, agent-preset/selected, tools/change, and immediately before each step's tool-schema assembly, so preset switches, new MCP tools, restored sessions, and subagents spawned with an explicit preset are all covered.
Configuration
Open this bundle's page in the Plugins view. isolatedPresets is a checkbox list of the
live preset roster; keepGlobal is a grouped checkbox list of global tool names. A name
already saved but missing from the built-in list still appears, checked, under
"Other tools already configured". Saving is one volatile mutation and applies from the
next step.
- id: preset-tool-gate
name: '@little_monkey/dsh-preset-tool-gate'
config:
isolatedPresets:
- minimal
keepGlobal: []| Field | Default | Meaning |
|---|---|---|
| isolatedPresets | [] | Agent preset ids whose Agents see only the tools their preset declares. Applies to subagents too: a standard parent that spawns a child with agentPreset: minimal gets an isolated child. |
| keepGlobal | [] | Global tool names that stay visible inside isolated presets, for example working_directory. Names that are not currently registered are ignored. |
Limits
- It hides tool schemas and blocks the hidden tools from execution; it does not change sandbox, approval, or permission policy.
- A tool registered after the last reconcile is hidden by the next step's alignment; the reverse (a tool becoming hidden between two steps) takes effect immediately.
- Only presets whose tools are declared in a preset scope benefit; a deployment without the agent-preset roster is unaffected.
forksubagents cannot select a preset, so only in-processspawnchildren can beminimal.
Verification
- Create or spawn an agent whose preset is in
isolatedPresets. - Inspect its first
request/headertool list (or the session JSONL): it contains only the tools its preset declares. - Confirm a non-isolated preset (for example
standard) still sees the host tools. - Switch an isolated session to another preset and back: the tool list grows and shrinks accordingly.
