Introduction¶
One of the core design principles of DeepSeek Harness (DSH) is its plugin architecture. During agent development, a model’s write or edit operations on files, as well as external bash/run_code calls, are often irreversible. Once something goes wrong, recovery may require manual intervention or tedious command-line operations.
dsh-rollback is a file-change rollback plugin for DeepSeek Harness. At the plugin layer, it listens to tool invocation results and execution hooks, captures the pre-change state, and provides rollback capabilities.
Plugin Overview¶
- Plugin Name: dsh-rollback
- Maintainer: Taler97
- License: MIT
- Core Functionality: Captures pre-change file images and supports rollback via tool or command line.
Installation and Enablement¶
This plugin is provided as a bundle and requires no modifications to the Harness core code.
-
Prerequisites
- Ensure the
dshCLI is installed and available in PATH. - Ensure
pnpmis installed and available in PATH (thedsh plugincommand depends on it).
- Ensure the
-
Installation Command
Run the following command for the target profile:
dsh plugin --profile demo add dsh-rollback
- Verification
After installation, the bundle is automatically included in the profile manifest. When starting a session, the model should be able to see therollback_filestool, or entering/rollbackbefore any changes are made should return the feedbackrollback: nothing to restore.
Core Features¶
- Change Capture: Captures the
beforeimage included inwrite/edittool results, as well as workspace snapshots taken beforebash/run_codecalls. - Storage Mechanism: Stores captured images in the workspace’s git object database or in a standalone snapshot store.
- Rollback Interface:
- Model Tool:
rollback_files {count} - User Command:
/rollback [count]
- Model Tool:
Usage Examples¶
User Command Rollback¶
Execute the following in the session chat input:
/rollback: Undo the most recently captured mutation in the current session’s working directory./rollback 3: Undo the three most recently captured mutations.
The output will list each restored file and its operation, such as restored or deleted.
Model Tool Rollback¶
The model can undo its own erroneous operations using the rollback_files tool. This tool has no prompt section; its parameter is {count}, which specifies the number of rollbacks.
Configuration Options¶
The plugin supports the following configuration options, which can be set by manually modifying the profile manifest or by specifying them in config:
- mode (
auto|git|snapshot): Storage mode.auto: Default. Uses git blobs if the workspace is a git repository; otherwise, uses snapshots.git: Stores all images as git blobs (requires a git repository).snapshot: Uniformly stores images as snapshot files.
- storeDir: Storage directory. Defaults to the
rollbackdirectory under the Harness home. - maxRecords: Maximum number of records kept in memory, default is 200. When exceeded, the oldest records are discarded.
- gitPath: Path to the Git executable, default is
git. - notifyModel: Boolean value. Whether to notify the model during manual rollback (defaults to enabled).
Capture Scope and Limitations¶
- Capturable:
write/edit(requires the result to include abeforefield),bash/run_code(requires the workspace to be a git repository). - Not Capturable:
str_replace_editor,bashcalls outside of a git repository, and raw subprocess operations. - Scope: Rollback is limited to the current working directory of the invoking session.
Conclusion¶
dsh-rollback is a lightweight safety net that stores pre-change state using git or snapshots, allowing erroneous operations to be safely undone while an agent is running. All code is available under the MIT license, and the source code can be viewed on GitHub.