在基于 DeepSeek Harness (DSH) 的智能体开发中… -> English:
In agent development based on DeepSeek Harness (DSH), when integrating OpenCode-like models (such as opencode / opencode-go), outbound HTTP requests need to carry a session identifier (such as x-opencode-session) so that the gateway can recognize the session context. Manually injecting it is not only cumbersome but also prone to inconsistencies in multi-instance deployments. The plugin-based ecosystem of DSH provides standardized extension points. The following describes a plugin specifically designed to solve this problem.
dsh-opencode-session-id is a DeepSeek Harness plugin maintained by gausszhou. Its core value is to automatically inject the session ID into the outbound HTTP request Wire layer when using OpenCode models, enabling zero-configuration operation.
Core Features¶
- Automatic session header injection: Adds headers such as
x-opencode-session,x-session-affinity, andx-client-request-idto outbound HTTP requests. - Zero configuration: Enabled by default after installation; no additional configuration is required.
- Wire-layer interception: Wraps
fetchto inject headers at the network transport layer without changing the request body, URL, or method. - Deterministic hashing: Hashes the UUID portion of the session ID into an 8-character alphanumeric nanoid, improving security and reducing header length.
- Protocol coverage: Mainly covers
fetch-based protocols (such asopenai-completions,openai-responses, andanthropic-messages).
Installation and Activation¶
- Install the plugin:
Install it using the official package name into thewebprofile:
dsh plugin --profile web add "@gausszhou/dsh-opencode-session-id"
- Reload the service:
After installation, restart the dsh-web process to activate the plugin:
systemctl --user restart dsh-web
Common Usage¶
- View logs: Enable debug mode to view the mapping from raw IDs to Wire Tokens:
journalctl --user -u dsh-web -f | grep opencode-session-id
- Configure verbose: Enable detailed logging in the configuration file:
- id: opencode-session-id
config:
verbose: true
Use Cases and Notes¶
- Use cases: Running OpenCode models with DSH in scenarios that require session consistency with the OpenCode Gateway.
- Notes:
- This plugin only supports
fetch-based protocols and does not covertransport: websocket. - The Wire Token is a one-way SHA-256 hash of the UUID portion and cannot be reversed to restore the original session ID.
- Modifying nanoid-related settings (such as
nanoidLengthandnanoidAlphabet) may break association with older records; adjust carefully.
- This plugin only supports
After the steps above, DSH will automatically carry the correct session headers when invoking OpenCode models. The plugin accomplishes session tracking through Wire-layer interception without interfering with business logic. For more details, see Plugin Directory or GitHub repository.