You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Send x-opencode-session header on API requests (required by OpenCode Go from 09/05) #2317
Hi — we operate the OpenCode Go managed-inference API, and 280 of your users' orgs call it through MiMoCode (UA mimocode/0.1.13 ai-sdk/provider-utils/4.0.23 runtime/bun/1.3.14).
Starting 09/05, requests without an x-opencode-session header will error on our side — we need a stable per-conversation ID for routing/optimization. MiMoCode doesn't send it in any version we've seen.
Ask: include x-opencode-session: <stable-id-per-conversation> on all outbound inference HTTP requests. Any stable UUID per conversation works. Happy to confirm from our telemetry once a build ships it. Thanks!
Reacted by xu-yi, fiyqkrc, ricardocmc, chenwgm-eng, pcmlab-uepb, peterp-star, guilhermelucena-png, romeo88845, RXDCODX, Guillermo Movia and 14 more
It adds x-opencode-session next to the existing x-session-affinity in session/llm.ts, carrying the same stable sessionID under the same non-ephemeral condition — so it's a real per-conversation ID, not one per process or per install. Tests cover both the normal and the ephemeral path.
@thdxr happy to have you confirm from your telemetry once a build ships it.
Heads up that the PR is still waiting on maintainer approval to run CI (first-time contributor), so it hasn't been reviewed yet — flagging because of the 09/05 date.
@romeo88845 as a stopgap you can set the header yourself, per model:
User-side workaround for this issue (works on the released build, no binary patch)
Confirmed on v0.1.14: MiMoCode already computes the stable per-conversation ID and sends it as x-session-affinity — it just never sends the second name OpenCode Go asks for:
$ grep -a -c 'x-session-affinity'"$(command -v mimo)"# 1
$ grep -a -c 'x-opencode-session'"$(command -v mimo)"# 0
So the minimal fix is putting the same value under a second header name — exactly what #2327 does in session/llm.ts. Until that merges, MiMoCode's documented chat.headers hook covers it from userland.
Install. Save as ~/.config/mimocode/hooks/opencode-session.ts (or <your-project>/.mimocode/hooks/). File hooks hot-reload on the next turn — no restart. Zero dependencies, nothing else to install.
// Workaround for XiaomiMiMo/MiMo-Code#2317 until #2327 ships.// MiMoCode already sends the stable per-conversation ID as `x-session-affinity`;// OpenCode Go additionally requires it as `x-opencode-session`.constTARGET_PROVIDERS=newSet(["opencode-go","opencode"])exportdefault{"chat.headers": async(input,output)=>{if(!input.sessionID)returnif(!TARGET_PROVIDERS.has(input.model?.providerID))returnoutput.headers["x-opencode-session"]=input.sessionID},}
Verify.
$ mimo run -m opencode-go/deepseek-v4-flash "reply ok"
Before: Request is missing x-opencode-session and cannot be routed efficiently (hard reject).
After: normal response. Other providers are untouched — the hook returns early.
Caveats
Ephemeral requests (session title / summary) do not pass through chat.headers, so they still lack the header. That matches fix(session): send x-opencode-session on outbound requests #2327's non-ephemeral condition, and this issue's ask is per-conversation.
The value is input.sessionID — the same opaque ID already sent as x-session-affinity, so no new identifier is invented and no routing assumption changes.
Retire it once a release ships the fix — and check, don't assume an upgrade fixed it:
$ grep -a -c 'x-opencode-session'"$(command -v mimo)"# ≥1 ⇒ built into the client, delete the hook
To disable, rename the extension (opencode-session.ts.bak) or delete the file. The loader glob is {hook,hooks}/*.{js,ts}, so a .disabled.ts name would still be loaded.
验证:mimo run -m opencode-go/<模型> "回复ok"。装之前报 Request is missing x-opencode-session and cannot be routed efficiently(硬拦截),装之后正常返回;非 opencode* provider 不受影响(钩子里提前 return)。
[ opencode-session.js
](url) Linux 上面的tui用前面Pegasus-lt老哥的hooks就行,如果用Xiaomi Mimo desktop 内测版的同学,可以用这个插件,Windows下,MAC不太清楚hooks能不能加载,反正Windows客户端没法加载hooks。
[ opencode-session.js
](url) Linux 上面的tui用前面Pegasus-lt老哥的hooks就行,如果用Xiaomi Mimo desktop 内测版的同学,可以用这个插件,Windows下,MAC不太清楚hooks能不能加载,反正Windows客户端没法加载hooks。
那个人也是我,Deepseek分析的,我没看懂就给删了 T_T
----- 原始邮件 -----
发件人:MeiHuaGuangShuo ***@***.***>
收件人:XiaomiMiMo/MiMo-Code ***@***.***>
抄送人:Pegasus-lt ***@***.***>, Manual ***@***.***>
主题:Re: [XiaomiMiMo/MiMo-Code] Send x-opencode-session header on API requests (required by OpenCode Go from 09/05) (Issue #2317)
日期:2026年09月16日 12点03分
MeiHuaGuangShuo left a comment (XiaomiMiMo/MiMo-Code#2317)
[
opencode-session.js
](url) Linux 上面的tui用前面Pegasus-lt老哥的hooks就行,如果用Xiaomi Mimo desktop 内测版的同学,可以用这个插件,Windows下,MAC不太清楚hooks能不能加载,反正Windows客户端没法加载hooks。
我是Windows下是v0.1.12 bun二进制编译版,实测是支持hook的。
我测试好像不太行啊……
我是使用插件的方式加载的,不是hook,参考我之前发的。在你这条消息之前有个人解释了为什么使用hook不行而插件可以,但是他删掉了
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
Activity
romeo88845 commentedon Sep 3, 2026
Is there a work around if MimoCode hasn't fixed this issue before 09/05?
Moviw commentedon Sep 4, 2026
PR is up: #2327.
It adds
x-opencode-sessionnext to the existingx-session-affinityinsession/llm.ts, carrying the same stablesessionIDunder the same non-ephemeral condition — so it's a real per-conversation ID, not one per process or per install. Tests cover both the normal and the ephemeral path.@thdxr happy to have you confirm from your telemetry once a build ships it.
Heads up that the PR is still waiting on maintainer approval to run CI (first-time contributor), so it hasn't been reviewed yet — flagging because of the 09/05 date.
@romeo88845 as a stopgap you can set the header yourself, per model:
{ "provider": { "<providerID>": { "models": { "<modelID>": { "headers": { "x-opencode-session": "<any-uuid>" } } } } } }That clears the hard error, but it's one fixed ID for every conversation, so you lose the per-conversation routing the header exists for.
est commentedon Sep 5, 2026
雷军!
金凡!萝福莉!还是优先看看这个issue吧!!影响天才程序员发挥了!!
DaweiTian commentedon Sep 10, 2026
@yanyihan-xiaomi 请尽快合并这个,opencode go没法用了,这里合并后,mimo desktop里面应该也就可以用了吧。
OToNaShi-4 commentedon Sep 12, 2026
@yanyihan-xiaomi 请尽快合并这个,影响我使用了,本来就是从 opencode 分支出来的不能忘本
Pegasus-lt commentedon Sep 15, 2026
User-side workaround for this issue (works on the released build, no binary patch)
Confirmed on v0.1.14: MiMoCode already computes the stable per-conversation ID and sends it as
x-session-affinity— it just never sends the second name OpenCode Go asks for:So the minimal fix is putting the same value under a second header name — exactly what #2327 does in
session/llm.ts. Until that merges, MiMoCode's documentedchat.headershook covers it from userland.Install. Save as
~/.config/mimocode/hooks/opencode-session.ts(or<your-project>/.mimocode/hooks/). File hooks hot-reload on the next turn — no restart. Zero dependencies, nothing else to install.Verify.
$ mimo run -m opencode-go/deepseek-v4-flash "reply ok"Request is missing x-opencode-session and cannot be routed efficiently(hard reject).Caveats
Ephemeral requests (session title / summary) do not pass through
chat.headers, so they still lack the header. That matches fix(session): send x-opencode-session on outbound requests #2327's non-ephemeral condition, and this issue's ask is per-conversation.The value is
input.sessionID— the same opaque ID already sent asx-session-affinity, so no new identifier is invented and no routing assumption changes.Retire it once a release ships the fix — and check, don't assume an upgrade fixed it:
$ grep -a -c 'x-opencode-session' "$(command -v mimo)" # ≥1 ⇒ built into the client, delete the hookTo disable, rename the extension (
opencode-session.ts.bak) or delete the file. The loader glob is{hook,hooks}/*.{js,ts}, so a.disabled.tsname would still be loaded.中文说明(同上一节)
根因:在 v0.1.14 实测,MiMoCode 已经把稳定的「每会话 ID」以
x-session-affinity发出去了,只是没发 OpenCode Go 要求的第二个名字x-opencode-session。所以最小修复就是把同一个值再加一个头名 —— 正是 #2327 在session/llm.ts里做的事。在该 PR 合并前,用 MiMoCode 官方的chat.headers钩子即可从用户侧补上。安装:存为
~/.config/mimocode/hooks/opencode-session.ts(或<项目>/.mimocode/hooks/)。下一回合热加载,无需重启,零依赖,代码见上。验证:
mimo run -m opencode-go/<模型> "回复ok"。装之前报Request is missing x-opencode-session and cannot be routed efficiently(硬拦截),装之后正常返回;非opencode*provider 不受影响(钩子里提前 return)。注意:
chat.headers,仍无该头 —— 与 fix(session): send x-opencode-session on outbound requests #2327 的 non-ephemeral 条件一致。input.sessionID,与已在发的x-session-affinity同源,不新造 ID、不改变路由假设。grep -a -c 'x-opencode-session' "$(command -v mimo)"确认 ≥1,别默认「升级了=修好了」;停用须改扩展名或删除(加载 glob 是{hook,hooks}/*.{js,ts},*.disabled.ts照样会被加载)。DaweiTian commentedon Sep 15, 2026
牛逼,感谢大哥,终于可以用了
MeiHuaGuangShuo commentedon Sep 15, 2026
刚让dsv4.1f做了一个,没想到有人已经做出来了。不过我是v0.1.12,我这个版本的使用下面的插件可以正常让会话标题带要求的请求头以正常请求实现短标题生成
DaweiTian commentedon Sep 15, 2026
[
opencode-session.js
](url)
Linux 上面的tui用前面Pegasus-lt老哥的hooks就行,如果用Xiaomi Mimo desktop 内测版的同学,可以用这个插件,Windows下,MAC不太清楚hooks能不能加载,反正Windows客户端没法加载hooks。
MeiHuaGuangShuo commentedon Sep 16, 2026
我是Windows下是v0.1.12 bun二进制编译版,实测是支持hook的。
Pegasus-lt commentedon Sep 16, 2026
Windows 上怎么用这个 workaround
一、文件放哪里
原生 Windows 上别放
hooks/——那个加载器在 Windows 上是坏的(原因见最后一节)。要放plugin/目录,二选一:%USERPROFILE%\.config\mimocode\plugin\opencode-session.ts<项目目录>\.mimocode\plugin\opencode-session.ts目录名写
plugin还是plugins都行,两个都会被扫到。二、文件内容
三、怎么确认生效
跑一条 opencode-go 的请求:
装之前会被上游硬拦,报
Request is missing x-opencode-session and cannot be routed efficiently;装之后正常返回。想更确定,可以看日志里有没有加载成功那一行:
四、两个容易踩的坑
export default { "chat.headers": ... }会抛Plugin export is not a function——那是 hook 文件的写法,在 Windows 上用不了。plugin/目录里有文件,MiMoCode 启动时会先等@mimo-ai/plugin@<对应版本>的后台安装完成,才开始加载插件;装不上(离线、代理不通)就会卡在启动阶段。先手动装好可以避免:五、什么时候可以删
上游把
x-opencode-session做进客户端之后(PR #2327 合入并升级到带修复的版本),本文件就没用了,直接删掉。判断办法:在 mimo 可执行文件里搜一下x-opencode-session,能搜到就说明客户端已经自带这个头。附:为什么不能用
hooks/Windows 上
hooks/目录里的文件永远加载不了。加载器先把钩子转译成临时文件,再用裸 Windows 路径去import,没有走pathToFileURL;E:\...\xxx.mjs会被当成模块名去解析,必然失败,日志里表现为Cannot find module ... failed to load file hook。这是上游已知问题,7 月就报了:#1813、#1753、#2359;v0.1.12 与 v0.1.14 的加载器逐字节相同,所以不是某个版本才坏的。修复是一行
import(pathToFileURL(tmpFile).href);在它合入之前,Windows 上只能走上面的plugin/路线。Pegasus-lt commentedon Sep 16, 2026
我测试好像不太行啊……
Pegasus-lt commentedon Sep 16, 2026
我也是拿Deepseek烧了一块钱搞的,用AI解决AI!
MeiHuaGuangShuo commentedon Sep 16, 2026
我是使用插件的方式加载的,不是hook,参考我之前发的。在你这条消息之前有个人解释了为什么使用hook不行而插件可以,但是他删掉了
Pegasus-lt commentedon Sep 16, 2026
Kassell commentedon Sep 18, 2026
不是我没看懂啊,是什么操作opencode,让生态去兼容你????自己不准守标准。在我看来这种pr就是给项目带来技术债,我是维护者的话我是不会合的
fix(session): send x-opencode-session on outbound requests
lcthe commentedon Sep 23, 2026
macOS 桌面版(Xiaomi MiMo Desktop)已用本 issue 里的插件方案解决,确认可用 ✅
环境
26.922.220226(macOS 26.2, Apple Silicon, Mac mini),内嵌 MiMoCode 引擎Request is missing x-opencode-session and cannot be routed efficiently. Please see https://opencode.ai/docs/go/#where-can-i-use-itopencode-go-chat→https://opencode.ai/zen/go/v1/chat/completions完整流程(在 macOS 桌面版上验证通过)
下载本 issue 中 @MeiHuaGuangShuo 提供的 opencode-session.js(桌面版适用:桌面版通过原生
import()加载 plugin,不走 hooks 加载器)。通读源码审计后(32 行,只做补头,无任何多余行为),放到全局插件目录:
(桌面版引擎实际读写
~/.config/mimocode/,与 CLI 共用配置目录;mimocode.jsonc里的 opencode-go provider 不用改。)完全退出桌面版(Cmd+Q)后重新启动,让内嵌引擎重新加载插件。
用 opencode-go 模型发消息测试:修复前必报上述错误,修复后正常回复。
确认两点
chat.headers,标题生成可能偶尔报错,主体对话不受影响,与 fix(session): send x-opencode-session on outbound requests #2327 的 non-ephemeral 条件一致。桌面版单独立了个跟踪 issue:#2477。等 #2327 合并发版后就删掉这个插件文件。
Ruandou commentedon Sep 29, 2026
要是每家中转站都来提一个这种SB 要求???
fix(session): send x-opencode-session on OpenCode Go requests (Xiaomi…