Introduction¶
When building agents with DeepSeek Harness (DSH), developers often encounter the situation where “I’ve clearly switched to a better model, yet responses are still slow.” The slowness may not actually come from the model — it’s more likely caused by plugins. When a set of plugins registers too many listeners on the event chain, tool definitions consume excessive context tokens, or listeners stacked on a particular path carry heavy execution overhead, overall performance gets dragged down.
dsh-plugin-profiler addresses this problem by providing a “plugin loading audit” capability. At runtime, it collects data on plugin event registrations, tool definition consumption, and chain latency, then outputs a “tax bill” via the /diet command, listing the current plugin set’s context cost, hot path latency, listener distribution, and suggesting “who to cut first.”
Plugin Positioning¶
dsh-plugin-profiler is a diagnostic plugin that runs within the DSH process. It does not alter any plugin behavior, nor does it introduce additional network calls or file writes. It simply attaches to the event bus and tool registry, collects data, and outputs results within the session. The plugin is maintained by liuhange789 and is released under the MIT license.
Installation & Activation¶
The official installation command is as follows:
dsh plugin add dsh-plugin-profiler
This plugin declares its own patch file (cordis.patch.yml) upon installation, so the above command is the only installation step required. Once installed, the /diet command is immediately available in the current session.
Core Capabilities¶
Context Tax¶
The plugin collects tool definitions sent with each request via ctx.tools.schemas() and estimates their token consumption. The output includes:
- Total number of tools per request and approximate token count
- The heaviest tool definitions with their corresponding token estimates
For example:
context 4 tools ≈ 210 tokens per request
heaviest: bash ≈ 68, read_file ≈ 54, apply_patch ≈ 45
Estimation is based on approximately 4 characters per token, serving as a relative weight rather than a billing basis.
Hot Path¶
The plugin instruments the event chain to measure the wall-clock time of “the remaining chain after agent/pre-step, agent/request, llm/stream setup, and tools/pre-execute,” including built-in listeners but excluding tool execution bodies and provider calls. This reflects the overall overhead along an event path.
Example output:
hot path 1 call, 37.3ms of host work (provider and tool body excluded)
Tool Call Latency¶
By measuring the time between tools/pre-execute and tools/result, the plugin records the wall-clock time of each tool call (grouped by callId). This includes pre-execution approval and post-execution processing, not just the tool body itself.
Listener Fan-out¶
The plugin takes a snapshot of listeners on the current event bus, listing how many listeners each plugin has registered and how many are attached to “hot events.” It provides recommendations in the output: “which plugin to look at first,” helping developers pinpoint potential performance bottlenecks.
Event Volume¶
The plugin tracks the event dispatch frequency of internal/dispatch, listing the top few most frequently called event types, helping developers understand which events are triggered most often.
Usage¶
The plugin does not require configuration files. After installation, use the following commands directly in the session:
/diet— Prints the “tax bill” and detail sections for the current plugin set/diet reset— Clears counters but retains the current listener list/profiler— An alias command equivalent to/diet
If the current session lacks a commands service, or if /diet is already occupied, counters will still be collected silently without interrupting session execution.
Use Cases¶
- During development, when you want to understand the real overhead of your current plugin set in terms of context, chain, and event dispatch
- When working with multiple plugins, when you need to identify which plugin has stacked too many listeners on the event chain
- When tuning response speed, when you need to distinguish between “the model itself” and “the plugin environment” performance differences
Notes¶
- The plugin runs with DSH process privileges. You should review the source code and license before installing
- The current plugin version is compatible with DeepSeek Harness
0.1.0-rc.7(@deepseek-ai/cordis4.x event bus) and Node.js^22.19.0 || >=24.0.0 - The plugin cannot measure “per-plugin milliseconds” or “the registrant of a tool”: due to the rc.7 event bus design limitation, the plugin can only see the existence of listeners and cannot wrap another plugin’s callbacks at runtime
- The listener snapshot is real-time: plugins loaded after installation will appear on the next invocation, and unloaded plugins will disappear from the snapshot
Summary¶
dsh-plugin-profiler provides a lightweight, non-invasive performance audit capability, helping DSH developers see clearly “what my plugin set is actually consuming.” If you’re suspecting plugins for slow responses, install it first, use /diet to check the current session’s context tax and hot path, then decide which plugin to optimize.
- Plugin directory page: https://www.skillhub.cn/plugins/liuhange789/dsh-plugin-profiler
- GitHub repository: https://github.com/liuhange789/dsh-plugin-profiler