Preface

Using a Coding Agent to modify code is fast, but prone to failure: a vague instruction, a loop that doesn’t exit, a few parallel tool calls, and a two-line change can turn into a rewrite of a dozen files, and by the time someone notices, the diff is too hard to review. Common responses rely on prompt constraints or post-hoc manual review, neither of which offers a deterministic boundary.

The dsh-change-budget introduced below takes a different approach: counting before supported write/edit tools run, and rejecting the first call that would exceed the limit before the tool body executes.

What is it

dsh-change-budget is a DeepSeek Harness (DSH) plugin that provides an independent, configurable change budget for each Agent turn. It covers three dimensions: unique file count, structured mutation call count, and committed UTF-8 byte count.

The project is maintained by Raphaelutumn, current version 0.1.0, licensed under MIT.

Core Features

  1. Per-turn independent budget. Each Agent receives an independent budget per turn. Counts are made separately for files, calls, and bytes without interference.

  2. Reject before tool execution. Counting happens before supported write/edit tools run. The first call that would exceed the limit is rejected before the tool body executes, preventing actual writes.

  3. Parallel safe. Pending calls reserve quotas synchronously, ensuring concurrent writes cannot collectively exceed the limit.

  4. Explicit counting scope. Only counts supported structured mutation calls:

    • write: counts UTF-8 bytes of content
    • edit: counts UTF-8 bytes of new_string
    • str_replace_editor: counts create / str_replace / insert operations
      Read-only calls and malformed calls are ignored. If str_replace is missing new_str, it is treated as an empty replacement and still counted as a mutation.
  5. Strict configuration. All config values must be positive integers. Invalid configuration causes the plugin to fail to load, rather than silently relaxing limits.

Installation and Enabling

Install from npm:

dsh plugin --profile web add @raphelutumn/dsh-change-budget@0.1.0

Note that the npm package name is @raphelutumn/dsh-change-budget. The scope spelling does not exactly match the GitHub username Raphaelutumn; refer to the original README for the installation command.

You can also download the v0.1.0 tarball and install locally:

dsh plugin --profile web add .\dsh-change-budget-0.1.0.tgz

To build from source, first clone the repository, then pack and install:

git clone https://github.com/Raphaelutumn/dsh-change-budget.git
Set-Location .\dsh-change-budget
corepack pnpm install
corepack pnpm pack --pack-destination .
dsh plugin --profile web add .\raphelutumn-dsh-change-budget-0.1.0.tgz

Remove the plugin:

dsh plugin --profile web remove dsh-change-budget

Following these steps installs the plugin to the web profile and takes effect. Regarding compatibility, the plugin has been verified on CI for Node.js 20/22/24 (Ubuntu, macOS, Windows), with the DeepSeek Harness peer range being ^0.1.0-rc.5.

Configuring the Budget

Three configuration items and their defaults:

Configuration Item Default Value Meaning
maxFilesPerTurn 12 Unique file count limit per turn
maxMutationsPerTurn 24 Structured mutation call count limit per turn
maxPayloadBytesPerTurn 262144 Committed UTF-8 byte count limit per turn

Override plugin config lines in the profile’s cordis.patch.yml, for example, relaxing the limits:

- id: change-budget
  config:
    maxFilesPerTurn: 20
    maxMutationsPerTurn: 40
    maxPayloadBytesPerTurn: 524288

All values must be positive integers; invalid configuration will cause the plugin to fail to load, rather than silently relaxing limits.

Run a Demo

The repository comes with a runtime demo: after installing dependencies, run

corepack pnpm demo

The demo allows modifications to two files; the third file is intercepted before the tool body executes.

In actual usage, the first call exceeding the limit receives an error like this:

Change budget exceeded for this turn: files would reach 13/12. Blocked path: "src/generated/client.ts". Raise the plugin limit or continue in a new user turn.

The error points out the exceeded dimension and value, as well as the intercepted path; when multiple dimensions are exceeded simultaneously, the error message reports all exceeded items together.

Suitable Scenarios and Notes

Suitable scenarios:

  • Keep small requests small: maxFilesPerTurn blocks the first modification that would go out of bounds, preventing vague instructions from evolving into large-scale rewrites.
  • Break repetitive edit loops: maxMutationsPerTurn limits the number of accepted structured write/edit calls within a turn.
  • Constrain parallel load: Synchronous reservation allows concurrent structured writes to share the same file, call, and byte budget.

Notes:

  • The plugin only restricts supported structured tools (specific operations of write, edit, str_replace_editor), not arbitrary Shell, PowerShell, or Bash writes, nor symlink or junction writes.
  • The plugin runs with the permissions of the current dsh process. You should check the source code and license before installing; the license for this plugin is MIT, and the source code is hosted on GitHub.

Summary

dsh-change-budget turns “how many files, calls, and bytes can be changed in a turn” into a configurable, executable hard constraint. Calls exceeding the limit are rejected before the tool body executes, eliminating the need for post-hoc remediation. If you are running a Coding Agent with DeepSeek Harness, you can try adding it to your profile following the steps above.

  • Community plugin directory page: https://www.skillhub.cn/plugins/Raphaelutumn/dsh-change-budget
  • GitHub repository: https://github.com/Raphaelutumn/dsh-change-budget