disyli/dsh-tool-call-stats
DeepSeek Harness plugin: per-process tool-call statistics (not token usage) — tool_stats tool with call counts, error counts, avg durations
已收录
0
Dev
Bundle 已验证
预览
功能介绍
进程内工具调用统计:提供 `tool_stats` 工具,按工具汇报调用次数、失败次数与平均耗时。
适合
- 希望诊断当前 DSH 进程中哪些工具调用最多、失败最多或耗时最长的开发者。
- 需要在运行期间查看简洁逐工具统计表的代理或操作人员。
不适合
- Token、费用或模型供应商用量统计;该插件只统计工具调用分发。
- 需要持久化或跨会话分析的场景,因为进程重启后计数会重置。
- 需要审计结果提交前即中止的调用,因为这类调用不会被计入。
README
dsh-tool-call-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?
Not to be confused with the token/cost trackers in the ecosystem (dsh-token-stats, dsh-usage-report, …) — this plugin counts tool-call dispatches, not tokens. Also unrelated to dsh-tool-stat (a descriptive-statistics math tool).
Status: built and verified end-to-end against the dsh v0.1 developer preview (headless profile, live DeepSeek session): both event listeners record real dispatches and
tool_statsreturns the table below. Upstream interfaces may still change during the preview.
Example output (from the verification run):
tool calls errors avg_ms
---- ----- ------ ------
bash 1 0 23
read 1 0 8
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 <name> add github:disyli/dsh-tool-call-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 <name> --dump-config # shows a "# == dsh-tool-call-stats" layer
dsh --profile <name>
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-call-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
常见问题常见问题
在启用了 DSH 的终端中执行已验证命令 dsh plugin --profile default add github:disyli/dsh-tool-call-stats。命令会解析公开 package 元数据,并保持插件与本页展示的目录身份一致。
兼容性以页面上展示的 bundle 与 profile 状态为准。如果某个 profile 尚未检测到,请先保持禁用,并在生产启用前阅读仓库文档。
GitHub 链接和 activity 元数据是 release 与维护状态的来源。新版本发布后重新查看本页,确认目录已经观察到最新版本。