Introduction

When debugging agents in DeepSeek Harness (DSH), it is often necessary to confirm which system, messages, tools, and invocation configurations compose the actual provider-neutral request assembled by each AgentLoop. It is also necessary to compare the differences between this request and the previous attempt. dsh-context-lens is a read-only context observation plugin. It records the provider-neutral requests assembled when each AgentLoop calls the model and adds a “Context” tab to the Harness session.

It does not modify the requests sent to the LLM, nor does it register callable tools for the model, nor does it capture network packets.

Plugin Positioning

dsh-context-lens is DeepSeek Harness’s context observation plugin, used to inspect, measure, search, and compare the provider-neutral requests assembled by each AgentLoop. It is suitable for troubleshooting issues such as prompt assembly, context sources, request volume, and attempt variations.

The request here refers to the provider-neutral GenerateOptions entering the Harness llm/stream scheduling seam. The provider adapter can still convert it into the vendor’s own HTTP payload later; this plugin does not capture network packets.

The license is MIT.

Core Features

  • Records the provider-neutral requests assembled when each AgentLoop calls the model.
  • Adds a “Context” tab to the Harness session.
  • Views the provider, model, system, messages, tools, and invocation configurations for each turn / step / attempt.
  • Displays named sections corresponding to the final system prompt; content whose source cannot be determined is marked as “unattributed” without guessing.
  • Displays source information such as skills, AGENTS.md, plugin context, and session references recorded in the Harness Session.
  • Displays UTF-8 bytes, UTF-16 code units, Unicode code points, and logical JSON bytes.
  • Displays explicitly labeled estimated token counts; it does not pretend to be the precise result of a provider tokenizer.
  • Supports search, raw/structured viewing, attempt comparison, and diagnostic JSON export.
  • Read-only observation; does not modify requests sent to the LLM, nor does it register callable tools for the model.

Installation and Enablement

Verified Environments

Verified versions are as follows:

Item Verified Version
Context Lens 0.1.0
DeepSeek Harness 0.1.0-rc.5
Node.js ^22.19.0 or >=24.0.0
Interface web profile

This project only provides verified promises for the versions in the table, not assuming other RC versions share the same events, client slot, and bundle contracts.

After downloading dsh-context-lens-0.1.0.tgz from GitHub Releases, install the plugin, then check the configuration and start the web interface:

dsh plugin --profile web add ./dsh-context-lens-0.1.0.tgz
dsh --profile web --dump-config
dsh web

dsh-context-lens bundle layer and context-lens row should appear in the output of --dump-config.

If you are running the CLI from the DeepSeek Harness source code repository, prefix the commands with pnpm:

pnpm dsh plugin --profile web add /path/to/dsh-context-lens-0.1.0.tgz
pnpm dsh --profile web --dump-config
pnpm dsh web

GitHub Source Code

Pin to a specific tag or commit, do not follow moving branches:

dsh plugin --profile web add github:1014029855/dsh-context-lens#v0.1.0

The repository commits the built lib/. pnpm 10+ may still require allowing Git dependency execution of prepare in the profile’s pnpm-workspace.yaml:

allowBuilds:
  dsh-context-lens: true

Only authorize reviewed and pinned source code. If you do not want to allow build-on-install, it is recommended to use the release tarball.

Typical Usage

First, start dsh web, create or open a session, and complete at least one agent turn, then view a request from the “Context” tab.

  1. Start the web interface:
dsh web
  1. Create or open a session, and complete at least one agent turn.
  2. Open “Context” next to Chat / Trajectory.
  3. Select an attempt from the attempt list to view volume, source, raw values, and differences from the previous one.
  4. When you need to submit a bug, use the JSON export on the page. The exported file may contain the reconstructed raw context, please review it before sharing.

Data and Local API

dsh-context-lens does not create a persistent copy of the raw prompt, message, or tool schema.

  • Raw requests only exist briefly in the real-time collection path.
  • The sidecar writes to $DSH_HOME/context-lens/v1, saving only index references, measurements, spans, times, health status, and HMAC.
  • Fingerprints use a randomly generated key per installation to calculate HMAC-SHA-256, not raw SHA-256.
  • The local API only supports GET / HEAD, checks the loopback peer and Host authority, and returns Cache-Control: no-store. Do not expose it directly to LAN or the public internet.

Configuration

Default configuration items are as follows:

Field Default Value Meaning
persistMetadata true Whether to write sidecar containing only metadata
maxAttemptsPerSession 500 Maximum attempt indices to retain per Session
charsPerEstimatedToken 4 UTF-16 code units corresponding to each estimated token

Override the full config in a later profile cordis.patch.yml layer:

- id: context-lens
  config:
    persistMetadata: true
    maxAttemptsPerSession: 250
    charsPerEstimatedToken: 4

The DSH patch replaces the entire config of this row; it does not deep merge.

Update and Uninstall

When updating the plugin, you can use the release tarball:

dsh plugin --profile web add ./dsh-context-lens-0.1.0.tgz

To uninstall the plugin:

dsh plugin --profile web remove dsh-context-lens

Restart dsh web after updating or uninstalling. Harness does not automatically delete plugin data on uninstall. If you also want to delete the capture index and HMAC key, stop all Harness processes first, then delete $DSH_HOME/context-lens/.

Troubleshooting

Cannot see “Context” tab

  1. Run dsh --profile web --dump-config and confirm that the output contains dsh-context-lens and context-lens.
  2. Restart dsh web.
  3. Perform a hard refresh on the browser.

Model requests not captured

Collection only starts after the plugin is loaded. Restart the Web profile, then create a new session and send a message. The health endpoint without prompt/message content is:

/context-lens/api/v1/health

recordedAttempts should grow with real AgentLoop requests. ignoredLlmStreams counts auxiliary calls such as title generation and compression, not errors.

Installing local tarball fails

Put the tarball in a short path without spaces, then pass that path to dsh plugin add. Do not use a link: dev checkout as evidence of release compatibility; release acceptance should use the packaged tarball.

Applicable Scenarios and Notes

dsh-context-lens is suitable for scenarios using DSH web profile and needing to view the provider-neutral requests assembled by each AgentLoop. It turns attempt into a searchable, comparable, and exportable diagnostic object, facilitating inspection of context assembly and volume changes.

Please note the following:

  • Token counts are estimates and do not pretend to be the precise result of a provider tokenizer.
  • It does not capture vendor HTTP payload and does not replace provider-side debugging.
  • It runs with the permissions of the current dsh process; check the source code, dependencies, and MIT license before installing.
  • Auxiliary LLM streams (such as title generation, compression) will be ignored and are not considered errors.
  • Harness is still in the RC stage and evolving rapidly; after upgrading, it is recommended to re-run dsh --profile web --dump-config to check if the plugin row is normal.

References

  • GitHub: https://github.com/1014029855/dsh-context-lens
  • License: MIT