dsh-tool-stats
DeepSeek Harness 的单进程工具使用统计插件:添加 tool_stats 工具以报告调用次数、错误数和平均耗时。
AI 分析
核心用途是统计分析工具调用数据。适合需要了解哪些工具被频繁使用、失败率及耗时分布的 DSH 用户和开发者。
安装
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:disyli/dsh-tool-stats说明文档
阅读完整 README ↗dsh-tool-stats
A tiny community plugin for DeepSeek Harness (dsh).
It records every committed tool call in the current harness process and exposes a tool_stats tool, so the model (or you) can ask at any point:
Which tools were used, how often did they fail, and where did the time go?
Example output:
tool calls errors avg_ms
---------- ----- ------ ------
bash 14 1 2350
read_file 9 0 12
web_search 3 0 1804
How it works
Everything in dsh is a plugin, and this one is deliberately minimal — three seams, ~100 lines, no build step:
tools/execute(waterfall): wraps each dispatch to record its start time, then delegates vianext().tools/result(observer): counts each committed result per tool name and accumulates duration;result.isErrordrives the error counter.ctx.tools.register(defineTool(...)): exposestool_stats, which returns a canonical JSON array (output.schema) and renders a plain-text table for the model.
All state is in-memory and process-local. Nothing is persisted; restarting dsh resets the counters. When the plugin is unloaded, Cordis disposes both listeners and the tool automatically — no manual cleanup code.
Install
Into a profile (recommended)
dsh plugin --profile add github:/dsh-tool-stats
pnpm ≥ 10 will ask you to allow the package before running install scripts (this package has none, but the prompt may still gate the git install). Follow the hint dsh prints, then re-run add.
Verify the layer and start:
dsh --profile --dump-config # shows a "# == dsh-tool-stats" layer
dsh --profile
As a local overlay (source checkout)
From a deepseek-harness checkout, point a patch at the local file:
# stats.cordis.yml
- insert:
- id: tool-stats
name: '/absolute/path/to/dsh-tool-stats/index.js'
pnpm dsh web --patch ./stats.cordis.yml
Use
Ask the agent things like:
- "Use tool_stats to show tool usage so far."
- "Which tool failed the most in this session?"
Limitations
- Process-local only: counters reset on restart and are not shared across sessions.
- Calls aborted before the registry commits a result are not counted (their timing entries are garbage-collected after 10 s).
- Built against the dsh v0.1 developer preview; upstream interfaces may change ("THERE WILL BE COMPATIBILITY-BREAKING CHANGES").
License
MIT