rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:zlxlsy666/dsh-opencode-session-fallback
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
A small DeepSeek Harness (DSH) plugin that gives
session-less LLM requests on OpenCode routes a fallback sessionId, so auto permission presets stop
failing every tool call with 400 MissingSessionID.
No global fetch patching, no provider config changes, no official package overrides.
OpenCode / OpenCode Go reject inference requests that do not carry an x-opencode-session header:
400 {"type":"error","error":{"type":"MissingSessionID","message":"Request is missing x-opencode-session ..."}}
DSH's @deepseek-ai/dsh-llm-pi-ai adapter only lets pi-ai add that header when the request carries a
sessionId. Main conversation calls do carry one — but
@deepseek-ai/dsh-experimental-auto-review builds its reviewer request by hand without a sessionId.
So with the auto permission preset on an opencode-go route:
Auto review of tool "pwsh" failed; its body was not executed:
auto-review: reviewer ended with error INVALID_REQUEST: 400: {"type":"MissingSessionID", ...}
Wrap ctx.llm.stream once at startup. Requests that already carry a sessionId, or that target a
provider outside the configured list, pass through untouched. Only session-less requests on OpenCode
routes (in practice: the auto-review reviewer call) get the configured fallback id; pi-ai then adds
x-opencode-session on its own.
ctx.llm.stream(options)
├─ options.sessionId present .......... pass through (main chat, subagents, compaction, titles)
├─ provider not opencode/opencode-go .. pass through (official DeepSeek etc. untouched)
└─ session-less + OpenCode route ...... { ...options, sessionId: <fallback> }
Why not patch globalThis.fetch (what some other plugins do)? Because replacing the global fetch wraps
every outbound call of the host — including the app's own networking — and can take the whole UI down
with connection errors. This plugin only touches the LLM service method.
sessionIds are never replaced → per-conversation routing / prompt-cache affinity is preserved.deepseek provider) are not affected at all.ctx.llm.stream automatically.Plugins are assembled at DSH startup — restart DSH after installing.
dsh plugin --profile web add dsh-opencode-session-fallback
Or use the GUI: Settings → Plugins → install, package name dsh-opencode-session-fallback.
dsh plugin --profile web add git+https://github.com/zlxlsy666/dsh-opencode-session-fallback.git
dsh plugin --profile web add "file:C:\path\to\dsh-opencode-session-fallback"
The desktop application manages its own desktop profile: use its Plugin Manager UI for that profile
instead of the CLI.
After a successful start the log shows:
[opencode-session-fallback] active for providers [opencode, opencode-go], fallback session id "dsh-opencode-session-fallback"
Override with the same entry id in the profile's cordis.patch.yml:
- id: opencode-session-fallback
name: dsh-opencode-session-fallback
config:
providers: [opencode, opencode-go] # routes that need a session id
fallbackSessionId: my-stable-id # value used when the request has none
debug: false # log every injection
dsh plugin --profile web remove dsh-opencode-session-fallback
Restart DSH afterwards.
0.2.1-rc.2 (desktop) with opencode-go + deepseek-v4.1-flash,
where it fixed the failure end-to-end (auto preset, tools execute, reviewer returns normal allow/deny
decisions).ctx.llm.stream to exist (inject: ['llm']); otherwise the plugin logs a warning and does nothing.node --check lib/index.js
node test/smoke.mjs # 5 assertions, no DSH runtime required
MIT
OpenCode / OpenCode Go 要求每个推理请求都带 x-opencode-session 头,缺失会返回
400 MissingSessionID。DSH 的 dsh-llm-pi-ai 只在请求带 sessionId 时才让 pi-ai 补这个头,而
@deepseek-ai/dsh-experimental-auto-review 的 reviewer 请求是手工拼的、没有 sessionId。
结果:在 opencode-go 路由 + auto 权限预设下,每次工具调用先过 reviewer → reviewer 请求 400 →
审查失败 → fail-closed → 工具全部无法执行。
启动时包一层 ctx.llm.stream:
sessionId 的请求(主对话、子代理、压缩、会话标题)原样透传;deepseek)完全不受影响;x-opencode-session。不接管全局 fetch(那会把宿主自身的出网调用一起包住,可能直接让 UI 报 connection error),
也不修改 provider 配置、不覆盖任何官方包。
插件在 DSH 启动时装配,装完必须重启 DSH。
dsh plugin --profile web add dsh-opencode-session-fallbackdsh plugin --profile web add git+https://github.com/zlxlsy666/dsh-opencode-session-fallback.gitdsh plugin --profile web add "file:C:\path\to\dsh-opencode-session-fallback"桌面版的 desktop profile 由应用自己管理,请在应用的插件管理器里安装。
启动日志应出现:
[opencode-session-fallback] active for providers [opencode, opencode-go], fallback session id "dsh-opencode-session-fallback"
在 profile 的 cordis.patch.yml 用同 id 覆盖:
- id: opencode-session-fallback
name: dsh-opencode-session-fallback
config:
providers: [opencode, opencode-go]
fallbackSessionId: my-stable-id
debug: false
从插件管理器卸载(或 dsh plugin --profile web remove dsh-opencode-session-fallback)后重启 DSH,
ctx.llm.stream 会自动恢复。
DSH 0.2.1-rc.2 桌面版 + opencode-go 路由 + deepseek-v4.1-flash:修复后 auto 预设下工具正常执行,
reviewer 能正常返回 allow/deny 决策。
MIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。