Introduction¶
In DSH / Agent development, model gateways, proxies, or audit pipelines sometimes identify sessions via HTTP headers. dsh-session-header is a DeepSeek Harness plugin used to inject x-session-id into LLM provider requests issued by DSH, ensuring each call carries the corresponding harness session ID. Below is an introduction to its positioning, core behavior, installation methods, and verification methods.
What is it¶
dsh-session-header is maintained by homily707 and is licensed under MIT.
Its purpose is: to inject the x-session-id HTTP header into every LLM provider request issued by DeepSeek Harness, with the value taken from the harness session ID of the current call. The plugin operates at the provider layer, does not modify adapter code, and does not overwrite existing headers.
Core Features¶
- Injects
x-session-idinto LLM provider requests. The default value is theGenerateOptions.sessionIdof the current call, with thesession-branding prefix removed. - Uses
llm/streamwaterfall andglobalThis.fetchpatching to overridefetch-based adapters, such asllm-deepseekandllm-pi-ai. - Propagates session context via
AsyncLocalStorage, affecting onlyfetchwithin LLM call streams; concurrent sessions have header values parsed per call. - Does not overwrite existing headers with the same name; comparison is case-insensitive.
- Supports configuring a fixed value for each call; if neither a session ID is available nor a fixed value is configured, no header is injected for that call.
- Restores the original
fetchwhen the plugin is unloaded. - Does not touch
attributionHeaders().
Installation and Usage¶
The plugin requires the dsh CLI and Node ≥ 22.
As a bundle install:
dsh plugin --profile <name> add github:homily707/dsh-session-header
The package is plain JavaScript with no build scripts; it does not require the pnpm ≥ 10 build allowance. After installation, use --dump-config to view the configuration layer:
dsh --profile <name> --dump-config
Look for the layer marker in the output:
# == dsh-session-header
Confirm it exists and start:
dsh --profile <name>
If using a local checkout and loading via --patch overlay, you can insert the plugin configuration in the overlay. The following name must be the absolute path to the plugin’s entry file:
# my-overlay.yml
- insert:
- id: session-header
name: /absolute/path/to/dsh-session-header/index.js
config:
header: x-session-id
# value: my-fixed-session-id
Then run:
dsh --patch ./my-overlay.yml
Configuration options:
header: The name of the header to inject, defaults tox-session-id.value: Optional; if set, this fixed value is used for every call; otherwise, the session ID of the current call is used.
Typical Usage¶
Point the baseURL of a provider to a gateway that records request headers, or to an endpoint that echoes request headers, then start a session. The headers should look like:
x-session-id: ba104306-a748-4052-a6e3-ab60be2e4c1f
Use the session ID of the current call for each request; concurrent sessions parse header values per call via AsyncLocalStorage.
Use Cases and Notes¶
Suitable for DSH scenarios in gateways, proxies, or audit systems that perform routing, caching, or auditing based on session headers, and also for configurations that require overriding fetch-based LLM adapters.
Notes before use:
- The plugin runs with the privileges of the current
dshprocess; you should check the source code and license before installing. - The plugin is provider-neutral and will not overwrite existing headers. The
llm-deepseekadapter itself sendsx-deepseek-harness-session-id; this plugin does not overwrite existing headers. - If no session ID is available and no fixed value is configured, the call will not receive a header.
- The plugin patches
globalThis.fetchat runtime and restores the originalfetchupon unloading.
Links¶
- Community directory page: https://www.skillhub.cn/plugins/homily707/dsh-session-header
- GitHub: https://github.com/homily707/dsh-session-header