dsh-context-explorer: Inspect the Context Sent to the Model by Sessions in the Web UI

Preface

When running a Session in DeepSeek Harness (DSH), the model receives a single, rendered prompt: system prompts, tool schemas, and history messages all occupy the same context window. Logs often contain only dialogue summaries, making it difficult to see how many tokens each segment occupies, their order, or where truncation occurs. Debugging context bloat, overly long tool definitions, or compaction effectiveness often requires a lot of guesswork without a visual view.

dsh-context-explorer is a community-maintained client plugin that adds a “Context” tab to the right sidebar of the Harness Web UI. It uses a token grid and a segment list to display the content composition sent to the model by the Session. Below is an introduction to its positioning, panel capabilities, installation methods, and usage limitations.

What is this

dsh-context-explorer (npm package name dsh-context-explorer, current version 0.1.1) is maintained by LionNatsu under the MIT license and is not affiliated with or endorsed by DeepSeek. The plugin is split into two halves: Host and Browser. index.js collapses the Session into a view, while client.js renders the tab, grid, and list.

In short: it visualizes the context window from the perspective of the last request within the DSH Web UI—showing how much space the system prompt, tool blocks, and individual messages occupy, and how the entire window is filled.

Core Features

After installing and loading the profile, a Context Explorer tab appears in the right panel (see locale/*.json for multilingual names).

Displays {used} / {total} used: used is the prompt size reported by the provider for the last request; if no report is available yet, it uses the total calculated by the panel itself. total is the context window length; it displays — if the Host has not yet provided the window size. Hover over the text to see the meaning of each number.

Composition Chips

Lists the content types present in the current view, sorted by token count (descending). Each item contains an 8x8 color block, the type name, token count, and its proportion of the panel’s total; these also serve as the grid legend. Clicking a chip filters the list to show only segments of that type; clicking again removes the filter.

Token Grid

The entire context window (including unused portions) is sliced into equal squares, with each square representing a segment of the window. Occupied squares are colored based on the content type with the highest occupancy in that segment; if a secondary type occupies at least 35% of the same square, a diagonal mix is applied. Areas exceeding the actual context length are tiled in a dark “free” color. Each square is 7 device pixels with a 1-pixel gap, maintaining a consistent physical size across different zoom levels. Hovering displays the type name; clicking opens the details of the segment to which that square primarily belongs.

Segment List

Each row corresponds to a region in the order seen by the model: a color block, a one-line summary, a “clipped” marker if necessary, and the token count with its percentage. Numbers reported directly by the provider are shown as is; numbers estimated by the plugin using the same heuristics as the Harness are marked with ≈. The summary explains “what this segment is” before expansion—for example, turns containing only tool calls are summarized by call name, JSON results by leading fields, and others by the first line of prose. Clicking a row expands the actual fragment received by the model (including role markers, etc.), not just the summary; truncation explanations are handled by detail.clippedNote in the expanded body. You can switch between “Model Order” and “Sort by Size.”

If there is no view available or the view contains no regions, the panel clearly prompts this instead of showing an empty shell. Collapse failures print an error above the title; rendering errors replace the entire tab content.

Where the numbers come from

The usage in the header prioritizes the provider’s count for the last request. For individual regions, if the provider has itemized counts, those are used; otherwise, a fixed heuristic identical to DSH context metering is used (approx. 1 token per 4 UTF-16 code units, plus fixed overhead for content blocks and messages), marked with ≈. Estimates reflect composition rather than billing accuracy and may drift depending on the text’s language.

Installation & Activation

Execute the following under the target profile (dsh plugin passes arguments to that profile’s pnpm; --profile specifies the profile name):

dsh plugin --profile <name> add dsh-context-explorer

Alternatively, you can perform the same installation via the Web UI’s Plugins page: click Add plugin and enter the package name, GitHub URL, or local directory path.

The package declares dsh.bundle.patch → ./cordis.patch.yml, which applies a line of Host-side configuration when the profile is next loaded. The runtime code is JavaScript within the repository with no build step or install scripts, so build permissions are not required when installing via github:. It requires Node ^22.19.0 or >=24.0.0. The README states it has been verified on @deepseek-ai/dsh 0.2.0-rc.2; the plugin does not declare version gating, so if upstream extension points change, it may manifest as a missing or empty panel rather than an installation refusal.

Host-side changes usually require restarting the DSH process; the browser half is loaded by the client module system and will hot-update automatically. If you modify Host-side index.js, serve.js, or estimate.js, and the default HMR does not watch the source directory, you need to restart, configure root for hmr in the profile patch, or reinstall via a different path for changes to take effect.

Typical Usage

  1. Install the plugin into your frequently used profile using the command above, start or reload the Harness, and open the Web UI.

  2. Select the Session you want to observe and open the Context tab in the right sidebar.

  3. Initiate or wait for a model call so the panel can obtain the prompt size reported by the provider; check the used / total in the header and the proportion of color blocks in the grid.

  4. Use composition chips to filter a specific content type (e.g., tool envelope, system prompt), click a row in the list to expand it, and verify if the fragment matches expectations; note that rows marked clipped only retain the beginning of the fragment (single message fragment cap is 4000 UTF-16 code units).

  5. Switch between list sorting methods to quickly identify the largest regions.

The above flow is derived from the README’s description of panel interactions and requires no additional configuration files.

Use Cases & Notes

Who it is for: Developers building or debugging Agents in DSH who need to check if system prompts and tool schemas are crowding out context, or who want to understand how the window is filled after compaction or multi-turn messages.

Permissions & Security: The plugin runs with the permissions of the current DSH process. Before installing, you should read the source code and MIT license of the GitHub repository, and acknowledge the estimate.js and serve.js reused from the DeepSeek project as noted in THIRD_PARTY_NOTICES.md.

Known Limitations (Accept before use):

  • The displayed body is a reconstruction of the official serving implementation (transcribed by serve.js), not the raw request body captured from the API; Session logs do not store the request body.
  • The panel displays content by region shards, not as a continuous prompt; the system prompt (earliest hoist), ## Tools block, etc., each form a shard; long messages will be truncated and marked as clipped.
  • There is no automated browser visual testing; layout relies on manual inspection.

The community plugin directory entry can be found at SkillHub; this site is a community ecosystem index and has no official affiliation with DeepSeek / High-Flyer.

Conclusion

dsh-context-explorer turns the “context sent to the model by the Session” from a black box into a readable grid and segment list, facilitating token composition analysis and truncation troubleshooting within the Web UI. For installation commands, limitation descriptions, and architectural details, refer to the repository README.

  • Directory Page: https://www.skillhub.cn/plugins/LionNatsu/dsh-context-explorer
  • GitHub: https://github.com/LionNatsu/dsh-context-explorer
羽毛球分组比赛记分
小程序二维码

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

Xiaoye