dsh-turn-speed:Monitor "the current turn" output speed in Session Statistics

Introduction

When using DeepSeek Harness (DSH) for multi-step agent tasks, the official “Session Stats” modal provides aggregated metrics for the entire session: model duration, tool calls, average Time To First Token (TTFT), output speed (TPS), etc. While these numbers answer “how was this chat overall,” session-level averages mix multiple turns together, which can be easily misinterpreted when you only want to determine how fast the model ran in the immediately concluded turn and how long the user actually waited.

The dsh-turn-speed plugin described below (maintained by suufon, categorized as a client plugin) appends current turn readings below the official metrics. Its algorithm is derived from the same source as the official sessionStats projection in @deepseek-ai/dsh-session-stats, but the scope is narrowed to the current turn.

What is this

dsh-turn-speed is a web client plugin for DSH: after opening the “Session Stats” modal, it appends current turn metrics—TPS (decode scope), current turn end-to-end speed, TTFT, duration, output tokens, steps, and turn number—below the official “Output Speed (TPS)” row. A divider separates the official session-level rows from the plugin’s current turn rows to prevent “session averages” and “current turn” figures from being conflated.

What is added to the modal

Official native items and plugin-appended items are visually separated by a divider (styling reuses the modal title separator, spanning across the two-column grid to avoid breaking into a short dash). The layout is illustrated below:

Session Stats
──────────────────────────
Model Duration            12.4s
Tool Call Duration         3.1s
Avg Time To First Token (TTFT) 1.2s
Output Speed (TPS)      262 tok/s
──────────────────────────   ← Divider: Above are official native items
Current Turn Output Speed (TPS)   268 tok/s   ← This Plugin
Current Turn End-to-End Speed       231 tok/s
Current Turn First Token (TTFT)  1.1s
Current Turn Duration            18.7s
Current Turn Output Tokens     5,014 tok
Current Turn Steps               6
Turn                 Turn 42

Implementation is via DOM injection: appending dt/dd rows to the end of <dl data-session-stats-details>. Since the official modal lacks a registrable slot, the details list must be patched. The coupling points are limited to this attribute, <html lang>, and standard tag semantics, without relying on upstream hash class names. When the modal closes, the plugin rows are unloaded and cleaned up along with the panel; during each render, it verifies if the tail is still this plugin’s block and rebuilds it if necessary to converge with React updates.

What do the two speed rows represent

The plugin deliberately retains two types of TPS with different scopes; they should not replace each other:

Row Scope Question Answered
Current Turn Output Speed (TPS) Σ Current Turn Output Tokens ÷ Σ (First Token → Step Completion) How fast is the model generating: Excludes TTFT and tool wait times. Same algorithm as official “Output Speed (TPS)”, but scope is limited to the current turn.
Current Turn End-to-End Speed Σ Current Turn Output Tokens ÷ Current Turn Wall Clock Time How long did the user actually wait: Includes TTFT, tool calls, retries, etc.

The decode scope is usually higher than the end-to-end scope; the difference reflects waiting costs. The current turn metrics are aligned item-by-item with the official projection. For example, “Avg First Token” is Σ÷steps, not taking the fastest single step, to avoid self-contradiction between adjacent rows.

Where do the numbers come from

The plugin does not read the internal state of the official modal but collapses data from the Session Controller’s event window. The logic is ported line-by-line from the official apply logic:

ctx.sessions.list.getSnapshot().current   → Current Session ID
ctx.sessions.binding(id).eventSource      → Event Window { entries }

The collapse details match the official implementation: only one step is open at any given moment; First Token time takes the first available value in the assistant/attempt → live chunk → settlement flow; multiple settles in one step are counted only once; packet-based stream records restore time via time0 + accumulated dt, aligning with assistantStreamFirstTokenTime in @deepseek-ai/dsh-llm.

Installation and Activation

In the DSH ecosystem, plugins are installed via CLI. The community directory site SkillHub has no official affiliation with DeepSeek / High-Flyer. It is recommended to review the repository source code and the MIT license before installing. The plugin runs under the permissions of the current dsh process and shares the same origin as the host.

dsh plugin --profile web add github:suufon/dsh-turn-speed

To pin a version, add a tag:

dsh plugin --profile web add github:suufon/dsh-turn-speed#v0.2.0

After installation, you must restart dsh web: the web boot manifest is assembled when the service starts, so refreshing the page alone will not activate new plugins.

# Repository script: Detects DSH_HOME / dsh CLI and verifies /turn-speed-api/health
pwsh -File .\scripts\restart-web.ps1

Uninstall:

dsh plugin --profile web remove dsh-turn-speed

For immediate effect when modifying source code, use a local path without spaces:

dsh plugin --profile web add link:<local-path-without-spaces>

If the path contains spaces, use a junction to bypass this (PowerShell examples are provided in the README).

Typical Usage and Verification

Daily usage: Chat normally in the web client, and open “Session Stats” to see the current turn metrics below the official rows. No additional configuration is required.

Self-Verification and Diagnostics (Optional): The host provides a semi-open loopback route without authentication, facilitating confirmation of whether the plugin is active, whether the modal is visible, and if the collapse logic is correct, without needing to open browser developer tools:

curl http://127.0.0.1:3080/turn-speed-api/health
curl http://127.0.0.1:3080/turn-speed-api/state

/state returns latest (e.g., activated, rows, lastError, etc.) and pages; the last report is written to $DSH_HOME/storages/dsh-turn-speed.json. Failure of diagnostic routes does not affect the UI, but results in the loss of diagnostic information.

The repository runs verification scripts outside the browser:

node scripts\verify.mjs

The README states that this script contains 98 checks, covering bundles, collapse mathematics, modal patching, and host routing.

Applicable Scenarios and Notes

Who it is for: Agent developers who need to distinguish between “entire session” and “current/last turn” performance within DSH web; particularly those concerned with the difference between decode TPS and end-to-end TPS, as well as TTFT and step counts.

Known Boundaries (from README):

  1. The step currently in progress does not have a complete timing record (partial only contains turn/step/blocks). Speed-related readings are updated at step boundaries; “Current Turn Duration” ticks locally every second.
  2. If the latest turn has no settlement available for sampling, it will display the previous turn and change the label to “Previous Turn”, rather than fabricating numbers.
  3. Numbers are collapsed semi-locally in the browser; the host half is responsible for the diagnostic channel and disk persistence.

Conclusion

dsh-turn-speed scales the official session stats projection algorithm down to a single turn and clearly separates “how fast the model is” and “how long the user waited” in the modal using a divider and dual TPS scopes. Simply restart the web service after installation to use it.

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

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

Xiaoye