nobu121/dsh-opencode-session

Plugin插件 Native原生 ⭐ 9 Sessions & Context会话与上下文

Project Overview项目介绍

This is a native plugin built exclusively for DeepSeek Harness (DSH). It addresses a breaking change made to OpenCode and OpenCode Go API endpoints in September 2026, which requires all requests to include an x-opencode-session header, otherwise requests will fail with a 400 MissingSessionID error. The plugin automatically injects this required header into all relevant outgoing requests from DSH, while leaving all other requests untouched. It uses the existing DSH session ID by default, so the same session ID persists across all turns of a single conversation. This also helps keep OpenCode's prompt cache warm between turns.

To install the plugin, you can run the DSH CLI command dsh plugin --profile web add dsh-opencode-session to pull it directly from the public npm registry. If you have checked out the source code locally, you can run the same command with the local path to the repository instead. After installation, you must fully restart your DSH profile for the plugin to load, as bundle layers are only read at DSH startup. Once loaded, you will see a confirmation message in the DSH startup log that the plugin is active for your target providers. You can also customize configuration options without editing the package files.

The plugin works by listening to DSH's llm/stream waterfall event, and patches the global fetch function to inject the header only for matching requests. It has no external dependencies, as it is built entirely as plain ESM JavaScript that works with DSH's existing runtime. There are a few limitations to note: it only injects the header into chat/streaming requests, not one-shot model listing requests, so if your endpoint also requires the header for listing, you will need to open an issue. It also relies on DSH using Node's global fetch for network requests, so if DSH changes its network stack in a future update, the plugin may stop working. The plugin is released under the open source MIT license.

这是一个专为DeepSeek Harness(DSH)开发的原生插件,用于解决2026年9月5日后访问OpenCode和OpenCode Go模型提供商时出现的400 MissingSessionID错误。它会自动为DSH发出的模型调用添加要求的x-opencode-session请求头,并为同一会话保持固定不变的会话ID,不会修改其他提供商的请求,也不会覆盖已存在的同名请求头。

安装该插件可以通过DSH的CLI从npm注册表获取,也可以本地检出源码后通过CLI添加到当前配置。安装完成后需要完全重启DSH配置文件才能生效,启动日志会显示插件已针对目标提供商激活。用户可以自定义配置目标提供商列表、会话ID生成模式,还可以开启调试日志输出到指定文件。

插件基于DSH的llm/stream流钩子工作,仅对匹配的请求注入头信息,不影响其他任何请求。它存在一定限制:仅会给llm/stream流请求添加头,模型列表请求不会处理,如果OpenCode端点也要求列表请求带该头则需要提交issue。插件无外部依赖,采用MIT许可证开源。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 2 warnings2 项注意
  • No license declared - all rights reserved by default; ask the author before commercial use or redistribution未声明开源许可证 —— 默认「保留所有权利」,商用或再分发前先问作者
  • Only 9 stars - very few users, little community feedback星标只有 9,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add dsh-opencode-session

把 nobu121/dsh-opencode-session 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-opencode-session

A DeepSeek Harness (DSH) plugin that automatically sends the x-opencode-session request header on model calls routed to OpenCode / OpenCode Go providers — one stable session id per DSH conversation.

Why

Since 2026-09-05 OpenCode's relay requires an x-opencode-session header on API requests (tracked upstream in deepseek-harness discussion #5495); without it, requests fail with 400 MissingSessionID-style errors. Requests that share the same header value are pinned to the same upstream backend, which is also what keeps OpenCode's prompt cache warm across the turns of one conversation.

This plugin:

  • fixes the 400 by always attaching the header to OpenCode(Go) requests,
  • keeps the cache/affinity benefit by using a value that is unique per conversation and stable across that conversation's turns (by default the DSH session id itself, the same identity the official DeepSeek adapter already sends as x-deepseek-harness-session-id),
  • leaves every other provider, and every request that already carries the header, untouched.

Install

From the npm registry (once published):

dsh plugin --profile web add dsh-opencode-session

From a local checkout:

dsh plugin --profile web add ./path/to/dsh-opencode-session

Then fully restart your dsh profile (bundle layers are read at startup). The startup log shows:

[opencode-go-session-header] active for providers [opencode, opencode-go] with mode session-id

If you run DSH from a source checkout instead, load it as an overlay: pnpm dsh web --patch ./cordis.patch.yml.

Configuration

The plugin row lives in the bundle's cordis.patch.yml; all keys are optional:

- insert:
    - id: opencode-go-session-header
      name: dsh-opencode-session
      config:
        providers: [opencode, opencode-go]   # route keys to attach the header to
        mode: session-id                     # 'session-id' | 'uuid'
        debug: false
        debugFile: null                      # optional absolute path
  • providers — provider route keys whose requests get the header. The defaults cover the pi-ai catalog ids opencode and opencode-go; add your own route key when you serve OpenCode through a custom provider name.
  • mode
    • session-id (default) — header value = the DSH session id of the model call. Unique per conversation, stable across turns, compaction, retries and process restarts.
    • uuid — a random UUID derived once per DSH session id (opaque; kept in memory, so it resets when the process restarts).
  • debug — log every streamed call that receives the header via ctx.logger (the dsh process console).
  • debugFile — optional absolute path. When set, every streamed call that receives the header appends one JSON line ({"ts","provider","model","session","header","value"}) to that file — handy when the dsh console is not visible.

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-client-ui-skin-qingxiao 下一个 Next dsh-token-cost →