dsh-confirm-gate: Counting and braking agent persistence operations under full privileges

Preface

Running Agents in DeepSeek Harness (DSH) sometimes requires enabling danger-full-access: the sandbox restricts tools like pwsh, whereas full access means there are no hard boundaries. The model might write files, execute commands, and dispatch sub-agents continuously within a single conversation turn, turning the trial-and-error cost directly into token usage and disk changes. DSH’s built-in sandbox is responsible for “whether this action can be done”; this plugin answers a different question—“how many persistent operations have already been performed in this turn”—and provides reminders after quotas are exhausted, injects stop instructions, and finally utilizes the approval channel to solicit user confirmation upon reaching the hard limit. Below is an introduction to dsh-confirm-gate maintained by SteelUnion (npm package @sroada/dsh-confirm-gate, currently v0.1.2), along with how to enable and configure it in your profile.

What is this

dsh-confirm-gate is a DSH runtime plugin maintained by SteelUnion, categorized under admin-security in the SkillHub plugin directory. It hooks into tools/pre-execute, tools/post-execute, and agent/pre-step at the tool dispatch layer, maintaining an independent persistent operation counter for each conversation turn: the first few times only inject reminders; after exceeding the free confirmation quota, it injects “stop immediately” instructions; when the hard limit is reached, it returns { kind: 'ask' } to request confirmation. The documentation explicitly states: this is not a security boundary, but a cost boundary and direction correction; preventing malicious models or prompt injection should rely on DSH’s sandbox and approval channels. This plugin complements the sandbox and automatically yields (does not count) in sandbox or workspace-write modes.

Compatibility: Developed and verified on DSH 0.2.0-rc.2. peerDependencies require both @deepseek-ai/dsh and @deepseek-ai/dsh-tools to be >=0.2.0-rc.2. If DSH changes the plugin binding hooks in the future, the design will explicitly throw errors rather than silently fail.

Core Functions

Three-tier Behavior and Confirm Pass-through

The counter resets to zero at the start of each turn (reset on new user message by default). If the user message contains the configured confirmWord (default confirm, case-insensitive), the entire turn passes: no counting, no reminders, no interception.

Count Range (default freeLimit=10, hardLimit=15) Behavior
1 ~ freeLimit Pass, inject reminder text
freeLimit+1 ~ hardLimit-1 Pass, inject stop instruction
>= hardLimit { kind: 'ask' }, go through approval to ask for confirm

Non-persistent tools like file reading, grep, glob, web-fetch are never counted. Write file, edit, subagent, message-send are judged as persistent by tool name; pwsh / bash are compared against a whitelist based on command content (read-only PowerShell cmdlets are not counted; redirection, git, node, etc., are counted as persistent). One tool call counts as 1 instance, regardless of how many files are touched.

The author verified on a real Windows machine: under default thresholds, the model stops on its own and asks for confirm after receiving the stop instruction at the 11th/15th time; when permissions are hot-swapped in the session danger-full-access → workspace-write → read-only → back to full access, the plugin does not need a restart to silence in sandbox mode and resume counting upon returning to full access.

Automatic Yielding in Sandbox Mode

Reads the current sandbox mode for every tool call (preferring ctx.sessionProjections.stateOf(session, 'permissions').sandbox, falling back to ctx.shell.sandboxMode). No counting under read-only or workspace-write; counting occurs under danger-full-access, custom, or when the mode cannot be read (when unreadable, it tends to take effect to avoid “installing the plugin but being completely silent”).

Installation and Activation

The repository dist/ provides packages ready for installation; the official installation method is local path copying (file: copies rather than symlinks; after modifying source code, you need to remove and then add again):

# Replace <plugin-directory> with your local plugin directory (containing package.json and cordis.patch.yml)
dsh plugin --profile <desktop|web> add file:<plugin-directory>

The desktop GUI usually uses profiles\desktop, while dsh.cmd web uses profiles\web. If installed to the wrong profile, you can see the configuration with --dump-config but the plugin won’t load; you can check the process command line to confirm the actual profile.

To make ask effective when limits are exceeded, you need to set the approval of the full access preset to ask in the profile’s cordis.patch.yml (never will reject ask as deny):

- id: permission
  name: "@deepseek-ai/dsh-permission-presets"
  config:
    presets:
      danger-full-access:
        sandbox: danger-full-access
        approval: ask

The plugin runs with the permissions of the current DSH process; please check the GitHub source code and MIT license yourself before installation, and do not treat unreviewed third-party plugins as the sole protection.

Typical Usage: Adjusting Thresholds in Profile

All adjustable parameters are written in the profile’s cordis.patch.yml by inserting a plugin entry and passing config. Constraint: hardLimit > freeLimit, otherwise it will error on startup.

# ~/.dsh/profiles/<your-profile>/cordis.patch.yml
- insert:
    - id: confirm-gate
      name: "@sroada/dsh-confirm-gate"
      config:
        freeLimit: 0          # Zero tolerance: enter subsequent tiers before the first persistent operation
        hardLimit: 3
        confirmWord: 批准
        warningText: 停。无批准不得动写操作,先汇报。

Common fields (see official README for default values): freeLimit (default 10), hardLimit (default 15), confirmWord, reminderText, warningText, askReason, as well as include / exclude tool name wildcards, resetOnUserMessage (default true).

To verify if it is actually loaded: --dump-config is not enough; you can change DEBUG_PROBE to true in lib/index.js, then reinstall and restart, and check confirm-gate-boot.log in the system temporary directory. The appearance of [enter] pre-execute indicates the hooks are connected.

Applicable Scenarios and Notes

Scenario Suitable?
Full access granted, worried about infinite trial and error burning tokens Suitable
Want to ask user for confirmation after N writes Suitable
Read, search, web query uninterrupted Suitable (non-persistent not counted)
Acting as a sandbox against malicious models Not suitable, use DSH sandbox
Agent frameworks other than DSH Not applicable

Before use, please be aware of the limitations listed in the documentation: the default first 10 times only have reminders, no hard gate; confirm prevents misoperations in trusted user scenarios rather than injection; containing the recognition word passes the entire turn, so accidentally touching the recognition word during discussion will also pass; command judgment is based on name comparison, may over-count but won’t miss count; subagent counts on the main Agent. The plugin has zero external dependencies; the author estimates the model cost of developing this plugin at about 0.27 USD (see dist/COSTS.md in the repository).

Conclusion

dsh-confirm-gate uses per-turn counting and tiered reminders to give the model a chance to brake on its own when full access must be used, and hands the decision back to the user at the hard limit, with a clear division of labor from the DSH sandbox. Directory page: SkillHub — dsh-confirm-gate; Source code and Chinese instructions: GitHub — SteelUnion/dsh-confirm-gate.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye