Introduction¶
DSH (DeepSeek Harness) uses a modular, plugin-based architecture, and extended plugins can enhance workflow capabilities. When building agents or complex workflows, managing concurrency for model requests is a common pain point. Excessive concurrency may cause providers to return 429 errors or trigger risk-control bans, while a lack of monitoring makes it difficult to identify bottlenecks. The following introduces the dsh-concurrency-guard plugin, which hooks into DSH’s model request bus to provide concurrency control and monitoring capabilities.
Plugin Introduction¶
dsh-concurrency-guard is a DSH concurrency request monitoring and gating plugin.
The core problem it solves is preventing concurrency over-limit. The plugin tracks all in-flight model requests (including main sessions, in-process subagents, workflow-derived agents, session title requests, and compression requests) and queues subsequent requests using FIFO after concurrency reaches the limit, fundamentally avoiding provider account locks or bans caused by exceeding concurrency limits.
Core Features¶
This plugin provides the following capabilities:
- Request bus hooking: Hooks into DSH’s sole model request bus, the
llm/streamwaterfall, ensuring that all model invocation entry points are monitored and no bypass exists. - Full accounting: Tracks all in-flight model requests and supports classification by source (such as main session, subagent, plugin, compression, and title).
- FIFO gating: Uses a first-in, first-out (FIFO) strategy to prevent concurrency over-limit. After concurrency capacity is full, new requests are queued, so concurrency slots never exceed the limit.
- Session-level concurrency control: Supports session-level concurrency control and allows setting concurrency limits for specific sessions.
- Multi-interface support: Provides a real-time WebUI panel, HTTP JSON endpoints, disk-backed status files, and tools.
- History and interruption handling: Supports automatic cleanup of history, persistent statistics, turn interruption detection, and fail-safe mechanisms.
Installation and Activation¶
DSH plugins are installed in a profile. Each profile is an independent npm project directory. Plugin management is based on pnpm; do not install directly with npm.
- Run the installation command:
dsh plugin --profile web add dsh-concurrency-guard
(Note: This command automatically writes to dependencies and adds the plugin to `dsh.profile.bundles`)
-
After the first installation, restart the DSH host process to activate the plugin.
-
After restarting, verify using the following methods:
- Switch to the “Concurrency Monitoring” tab at the top of the session view.
- Ensure
GET http://127.0.0.1:3080/api/concurrency-guard/statusreturns 200. - Check whether the host logs show
[concurrency-guard] started.
Typical Usage¶
The plugin provides several ways to monitor and configure it:
WebUI Monitoring¶
At the top of the DSH session view, switch the view to the “Concurrency Monitoring” tab to view the real-time concurrency level and the list of in-flight requests.
HTTP API¶
Operate through HTTP JSON endpoints:
- View status:
GET http://127.0.0.1:3080/api/concurrency-guard/status
- Hot-update configuration:
POST http://127.0.0.1:3080/api/concurrency-guard/config
Body: {"mode": "monitor", "maxConcurrency": 8}
Code Invocation¶
In DSH workflow code, you can call it through the context object:
ctx.concurrencyGuard.configure({...})
Tool Invocation¶
The plugin provides command-line tools that can be invoked directly in model conversations:
* concurrency_status: View the current concurrency status (supports the {"full": true} parameter to view history).
* concurrency_session_list: List online sessions and their limits.
* concurrency_session_set: Adjust a session cap in real time (for example, {"action": "set", "sessionId": "...", "cap": 2}).
Use Cases and Notes¶
- Use cases: Suitable for scenarios requiring strict control of provider API concurrency quotas, or for complex architectures that require monitoring a large number of subagent and workflow-derived requests.
- Note: The plugin runs with the permissions of the current DSH process; inspect the source code and license before installation.