dsh-plugin-tool-trace: Tracking Tool Call Duration and Result Size

Preface

When building workflows with DeepSeek Harness (DSH), developers often need to monitor the actual performance of tool calls—such as abnormal latency or the token consumption of arguments and results—beyond just the conversation transcript itself. Traditional logging methods often inject massive amounts of data into the context, making them difficult to retrieve and lacking in aggregate statistical capabilities. This plugin provides a “zero model visibility” lens that records only key metrics without interfering with the context.

Plugin Introduction

dsh-plugin-tool-trace is a DeepSeek Harness (dsh) plugin. Its core responsibility is to trace the duration, argument volume, and result volume (recording only size, not content) of every tool invocation. Data is persisted to JSONL files generated monthly, and a /tools-stats command is provided to generate a leaderboard of slow tools.

  • Maintainer: 121212165
  • License: MIT

Core Features

  1. Slow Tool Leaderboard: Access /tools-stats. The system sorts by cumulative duration and displays the call count, cumulative duration, average duration, maximum duration, average result volume, and error count for each tool.
  2. Zero Model Visibility: All tracking data is written only to local files and does not enter the conversation context. This protects privacy and ensures the data is purely for human analysis.
  3. Fault Tolerance: If a process crash interrupts a write, partial lines are automatically skipped and counted. Calls that died mid-process (having a start but no end) are naturally ignored during aggregate statistics.

Installation and Activation

The installation process requires adding the package to a specified Profile via the DSH plugin command and modifying the configuration file.

  1. Execute the installation command (ensure pnpm is in your PATH):
dsh plugin --profile web add github:121212165/dsh-plugin-tool-trace

This command automatically runs the prepare script via pnpm to build the plugin.

  1. Configure the patch file.
    Locate the cordis.patch.yml in the root directory of this plugin repository and merge its content into $DSH_HOME/profiles/web/cordis.patch.yml.
    Note: This file defaults to an empty array []. Please merge the patch content into the array; do not append it directly. Appending will cause a YAML parsing error (reporting failed to parse overlay ... end of the stream or a document separator is expected).

  2. Restart dsh.
    Both the configuration layer and the client need to be restarted for the changes to take effect (the client distributes content based on the rev at startup; a hard refresh of the browser will not work).

Configuration

The plugin supports the following configuration options:

Field Default Value Description
dataDir ~/.dsh/tool-trace Directory for persisting JSONL logs
captureArgsSize true Whether to record the length of the argument JSON

Typical Usage

  1. View Statistics: Use the /tools-stats command in the DSH interface or terminal to view the slow tool leaderboard.
  2. View Logs: Navigate to dataDir (default ~/.dsh/tool-trace) to view monthly JSONL files and understand specific call metrics.

Notes

  1. Result Volume Precision: The extraction of result body size relies on the data shape of the downstream result. If content is a string, the size calculation is exact; if it is another shape (such as an array or object), the size is estimated via serialization.
  2. Live Mount Unverified: The plugin has not been verified for live mounting on a running dsh instance.
  3. Activation Conditions: The dsh process must be restarted for the plugin to take effect.

Closing

By persisting data to disk and performing aggregate statistics, this plugin helps developers shift their focus from “what was said” to “what was done and where the bottlenecks are.” For more details and source code, please visit GitHub or the Community Directory.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye