Skills Plugins MCP Prompt Model 导航 博客 资讯 我的中心
模型与提供方 #coding-agent#deepseek#deepseek-harness#dsh#dsh-plugin#header-injection

dsh-opencode-session-header

为 DSH 中的 OpenCode Go 按会话注入 x-opencode-session 请求头,修复 400 MissingSessionID 并保持 prompt 缓存路由最优。

beihzb @beihzb ⬇ 2 ★ 6 main

安装

dsh plugin --profile web add github:beihzb/dsh-opencode-session-header
下载安装清单

需要可复现安装时,可在仓库后追加 #commit 固定提交。

为 DSH 中的 OpenCode Go 按会话注入 x-opencode-session 请求头,修复 400 MissingSessionID 并保持 prompt 缓存路由最优。

该插件未提供要点说明,请参考仓库 README。

coding-agentdeepseekdeepseek-harnessdshdsh-pluginheader-injection
  1. 安装并启动 DeepSeek Harness:npx @deepseek-ai/dsh web
  2. 在终端执行上面的安装命令(CLI 会解析插件并核验来源)
  3. 用 dsh plugins list 确认已安装,必要时重启 Harness 生效

插件以当前 dsh 进程的权限运行,安装时可能执行代码。请先通读仓库源码与许可证,确认无破坏性命令与越权访问;本站只做索引,不对第三方插件安全性作担保。

代码仓库github.com/beihzb/dsh-opencode-session-header
许可证MIT
主要语言main
下载量2
GitHub 星标6
最近推送2026-09-07
收录日期2026-09-19
分类模型与提供方

事实信息来自公开插件目录快照(2026-10-03),介绍文案由本站再加工。

以下为插件仓库 README 全文(原始内容,由公开目录抓取整理)。

# dsh-opencode-session-header

[![npm version](https://img.shields.io/npm/v/dsh-opencode-session-header)](https://www.npmjs.com/package/dsh-opencode-session-header)
[![license](https://img.shields.io/npm/l/dsh-opencode-session-header)](./LICENSE)
[![node](https://img.shields.io/node/v/dsh-opencode-session-header)](./package.json)

Per-conversation `x-opencode-session` header injection for **DeepSeek Harness (DSH)** → **OpenCode Go**.

It fixes the `400 MissingSessionID` rejection **and** keeps OpenCode's per-conversation routing / prompt-cache optimization working — scoped strictly to `opencode.ai`, runtime-switchable without restart, zero dependencies.

[中文文档](./README.zh-CN.md)

## The problem

Since 2026-09-05, [OpenCode Go](https://opencode.ai/docs/go/) requires a stable `x-opencode-session` header on every inference request (used for routing and prompt caching). DeepSeek Harness ≤ `0.1.2-rc.1` sends no such header on any adapter path, so **every opencode-go model call fails**:

```
400: {"type":"MissingSessionID","message":"Error from provider (Console Go): Request is missing x-opencode-session ..."}
```

Upstream fix is tracked in [deepseek-harness discussion #5495](https://github.com/deepseek-ai/deepseek-harness/discussions/5495) but has not shipped yet. This plugin fills the gap locally.

## Why not the common workarounds?

| | Static `headers` in settings.yaml | Global `opencode_zen` profile (dsh-custom-header) | **This plugin** |
|---|---|---|---|
| Fixes the 400 | ✅ | ✅ | ✅ |
| Per-conversation id (cache / routing optimal) | ❌ one shared id → cache misses, slower & pricier | ✅ | ✅ real DSH session id |
| Other providers untouched | ✅ | ❌ rewrites UA + `x-opencode-*` on **every** host | ✅ `opencode.ai` only |
| Toggle without restart | — | — | ✅ JSON file flip |
| Extra dependencies | — | third-party plugin, client bundle | none |

## Install

```powershell
dsh plugin --profile web add dsh-opencode-session-header
```

or from a local clone / checkout:

```powershell
dsh plugin --profile web add "file:C:\path\to\dsh-opencode-session-header"
```

Then **restart dsh web** once — plugins load at boot. The startup log should show:

```
[dsh-opencode-session-header] loaded: header=x-opencode-session hosts=opencode.ai fallback=dsh-default
[dsh-opencode-session-header] runtime switch: \plugins\dsh-opencode-session-header.json ({"enabled":false} disables; missing file = enabled)
```

## Runtime switch (no restart needed)

State file: `/plugins/dsh-opencode-session-header.json` (defaults to `~/.dsh`):

```json
{ "enabled": false }
```

- `false` → injection off (all requests pass through untouched);
- `true` or **file missing** → injection on;
- the file is re-read on every LLM request, so toggling takes effect immediately.

## How it works

Two seams, both proven inside DSH `0.1.2-rc.1`:

1. **`llm/stream` waterfall observer** — wraps every adapter stream iteration in an `AsyncLocalStorage` carrying `GenerateOptions.sessionId` (stable per DSH conversation across turns, compaction and retries; fresh per conversation / fork / subagent).
2. **Fetch transport middleware** — stamps `x-opencode-session` **only** when the request host matches the allowlist (default: `opencode.ai` + subdomains). Value = the current session id, or the fallback id (`dsh-default`) outside any LLM context (e.g. model discovery). Every other host passes through byte-for-byte untouched.

The fetch pipeline runs under this plugin's own `Symbol.for` key (mechanics vendored from [`@aizigao/pi-fetch-pipeline`](https://github.com/aizigao/pi-fetch-pipeline), MIT), so it coexists with other fetch-patching plugins instead of clobbering them. Header merging follows the fetch spec: whichever of `init.headers` / `Request.headers` would reach the wire is used as the merge base.

## Testing

```powershell
npm test        # 13 assertions: injection, fallback, allowlist, runtime switch,
                # concurrent-session isolation, llm/stream propagation, subdomains
```

## Compatibility & retirement

- Built and verified against DSH `0.1.2-rc.1` (npm latest at release time).
- Depends on DSH outbound LLM traffic using the process-global `fetch`. If a future DSH build switches its network stack, the plugin silently stops injecting — the symptom is simply the 400 returning; uninstall then.
- Once upstream ships native per-conversation session headers ([discussion #5495](https://github.com/deepseek-ai/deepseek-harness/discussions/5495)), retire this plugin:

```powershell
dsh plugin --profile web remove dsh-opencode-session-header
```

then restart dsh web (optionally delete the switch file).

## Credits

- Fetch-pipeline mechanics vendored from [`@aizigao/pi-fetch-pipeline`](https://github.com/aizigao/pi-fetch-pipeline) (MIT); the fetch-layer approach on DSH was proven by [`dsh-custom-header`](https://github.com/Asaiuta/dsh-custom-header) (MIT) by [Asaiuta](https://github.com/Asaiuta).

## License

[MIT](./LICENSE)

数据来源:公开的 DeepSeek Harness 插件目录与各插件 GitHub 仓库。本站为独立第三方目录,与 DeepSeek、幻方(High-Flyer)及插件作者均无隶属或背书关系。

每日精选 Skill 推荐,免费送到你邮箱

输入邮箱,每天接收一个精选 AI Agent 技能推荐。完全免费,持续更新。

提交后我们会发送一封确认邮件,点击邮件里的链接才会开始收信。

完全免费,取消任意时间。我们不会发送垃圾邮件。