dsh-ocg-session-head: Filling In OCG Session Headers for DeepSeek Harness
verneuil/dsh-ocg-session-head
A DSH plugin that injects the x-opencode-session header per conversation for custom OpenCode Go routes, preventing 400 MissingSessionID errors.
dsh-ocg-session-head is a DSH plugin that supplies the missing session header for custom OpenCode Go routes. Custom OCG routes do not receive the official wrapper, so inference requests get rejected for lacking a session ID; this plugin writes one stable header value per conversation into the slot the host reserves for request headers. It offers two-gate route matching by provider key and host suffix, two session modes, and strict config validation, with zero dependencies, no global fetch replacement, and existing headers always taking precedence.
How to Install
dsh plugin --profile web add github:verneuil/dsh-ocg-session-head- Category
- Models & Reasoning
- Platform
- DSH Plugin
- Author
- verneuil
- Distribution
- Plugin
dsh-ocg-session-head Key Features
dsh-ocg-session-head Repo Summary
What Does It Do?
OCG Session Header is a DSH plugin for DeepSeek Harness that injects an x-opencode-session request header per conversation for OpenCode Go routes. It solves the problem of custom OCG routes missing the official wrapper, which makes inference requests fail with a 400 MissingSessionID error. The plugin only writes one header into the slot the host reserves for request headers, without replacing global fetch or using async local storage, and it has zero dependencies and no global side effects.
Core Features
- Per-session header injection: generates a stable
x-opencode-sessionvalue for each conversation that survives multiple turns, context compaction, and restarts. - Two-gate route matching: filters requests by a provider-key allowlist and a baseURL host-suffix allowlist, combined with OR logic so a fallback remains when the route key changes.
- Two session modes:
session-idreuses the host session id directly, whileuuidderives an opaque per-session identifier that stays stable within the process, with a tracked-session cap and oldest-first eviction. - Strict config validation: unknown keys, wrong types, invalid header names, and host-owned headers fail loudly with the offending field named instead of silently falling back.
- Safety guarantees: existing headers of the same name always win, requests without a session id pass through untouched, and internal errors only log a warning before continuing so inference is never interrupted.
How to Use This Plugin?
After enabling it in DSH, the plugin registers its listener through the host lifecycle and needs no manual trigger; the default config already applies to the ocg route. To adjust behavior, override the config by plugin id in the profile's cordis.patch.yml, where you can change the provider allowlist, host suffixes, header name, session mode, and debug switch, keeping in mind that an id-based override replaces the whole config. Verification has four steps: check the ready log at startup, enable debug to see an injection log per call, confirm normal chat no longer returns 400, and disable the plugin to see the 400 return immediately as reverse proof. The plugin requires DSH 0.2.2-rc.1 or newer; installing on older hosts is safe but the event never fires, which allows a staged install-then-upgrade check.
How to Troubleshoot This Plugin?
A 400 MissingSessionID response means the session header was not sent: first confirm the host version meets the requirement, then check whether the route key or baseURL host falls inside the allowlists, and enable debug to inspect the injection logs if needed. If plugin activation fails with a field name, fix the invalid key, type, or header name the message points to. If an entry fails to import, the install target was likely treated as a package directory rather than a packed artifact, so follow the official instructions and install from the packed file instead.
This page is an independent rewrite of the plugin's official README — for authoritative documentation and the latest changes, refer to the source: verneuil/dsh-ocg-session-head. The plugin is third-party code that runs on your machine once installed; inclusion does not imply endorsement — please review the source before installing.
DSH Plugin FAQ
