Preface¶
When developing agents using DSH, a common issue is that agents rely on summary data (such as directory counts) rather than first-hand evidence. This leads to misjudgments of data loss or abnormal states, resulting in erroneous modifications to core storage and causing application crashes. dsh-agent-guard is a DSH guardrail plugin designed for such scenarios. It requires agents to read evidence before executing operations and intercepts and backs up data during writes.
What is it¶
dsh-agent-guard is a DSH safety guardrail plugin. Its core value lies in: evidence-first read-only checks, write-time governance interception, and per-turn rollback point recording. This plugin has zero runtime dependencies, no network requests, and no telemetry data. It is maintained by user a5557.
Core Capabilities¶
Evidence-First Read-Only Checks¶
The plugin reads the first-hand identity header information of all sessions via the guard_inspect tool. It identifies and marks records with origin: "subagent" that are intentionally not registered by DSH internally, preventing internal data structures from being misidentified as data loss.
Write Governance and Interception¶
The plugin intercepts protected write operations at the tools/pre-execute stage:
1. Refuse writes when not stopped: Writes to core data are refused when DSH has not confirmed a stop.
2. Backup before allowing: Allowed writes must be backed up first, with a default limit of 8MiB per file. If the backup fails or exceeds the limit, the write is refused.
3. Circuit breaker mechanism: If the same path is written to twice consecutively with inconsistent checksums, the circuit breaker is triggered, requiring manual intervention.
4. Script generation interception: If agent-generated .bat/.cmd/.ps1/.sh scripts reference protected paths, they are marked as emit-script and refused.
Per-Turn Rollback Points¶
The plugin maintains per-turn rollback points. These points can be used to restore the state when destructive operations occur.
Client UI Integration¶
The plugin provides a client UI integrated into the sidebar and settings pages, displaying guardrail status, rollback points, and recent protected operations.
Installation and Activation¶
Installing the plugin requires specifying a profile. The plugin declares dsh.bundle.patch in package.json, so it will be mounted as a profile layer after the package is added.
# Install specific version from registry
dsh plugin --profile <profile> add dsh-agent-guard@0.1.0
# Install from local directory (path must be absolute)
dsh plugin --profile <profile> add <absolute-path-to-this-directory>
Typical Usage¶
The plugin provides command-line tools and also performs automatic interception via the UI.
Tool Commands¶
# Generate evidence report (read-only, does not modify any data)
guard_inspect(scope?, workspace?, maxSessions?, includeHeaders?, redact?)
# View guardrail status and logs
guard_journal(action?, limit?, snapshot?)
Automatic Interception Rules¶
The above interception rules take effect automatically after the plugin is installed. guard_journal with action: "trace" allows viewing details of a single operation, while action: "rollback" returns manual rollback instructions (no automatic rollback functionality).
Notes and Cleanup¶
Data Persistence¶
Uninstalling the plugin (dsh plugin --profile <profile> remove dsh-agent-guard) only removes the registration configuration and does not delete any data, including rollback points. To clean up, you must manually delete the data directory.
# Clean up rollback point data (manual operation)
rm -rf "$DSH_HOME/agent-guard"
pnpm Residue¶
The plugin does not clean up node_modules/.bin/dsh-agent-guard* shim files generated by pnpm; this is pnpm’s behavior, not residue from the plugin.
UI Limitations¶
The UI interface is strictly read-only. There are no repair, migration, or rollback buttons.
Conclusion¶
dsh-agent-guard provides a foundational security defense for DSH, ensuring that agents operate based on read evidence and preventing data corruption caused by misjudgments. Related documentation and source code can be found in the community directory or GitHub repository.
- Plugin Directory: dsh-agent-guard - SkillHub
- Source Repository: a5557/dsh-agent-guard