Skip to content

Send x-opencode-session header on API requests (required by OpenCode Go from 09/05) #492

Open

Description

@thdxr

Hi — we operate the OpenCode Go managed-inference API, and a large share of your users call it through ZCode (UA ZCode/3.x, ~33k orgs in the last week).

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. We measured all current ZCode builds (incl. 3.10.2) at ~0% header presence, so every ZCode user on Go will break unless the client sends it.

Ask: include x-opencode-session: <stable-id-per-conversation> on all outbound inference HTTP requests. Any stable UUID per conversation works; it just needs to be consistent across requests in the same session.

Happy to confirm the fix from our telemetry once a build ships with it. Thanks!

Activity

  1. github-actions commented on Sep 3, 2026

    @github-actions

    👋 感谢你的反馈,我们已经收到。

    • 维护者看到后会尽快回复你。
    • 状态保持为 status: 待评估,你可以随时补充信息。
    • 信息不全时我们会打上 needs: 更多信息 标签并 @ 你。

    👋 Thanks — we've received your issue.

    • A maintainer will get back to you as soon as we can.
    • Status stays at status: 待评估 (Triage); feel free to add context.
    • If we need more details, we'll add needs: 更多信息 and ping you.
  2. liushidai commented on Sep 7, 2026

    @liushidai

    搞快点,磨磨唧唧

  3. wangjianjq commented on Sep 8, 2026

    @wangjianjq

    补充一个 3.11.2 的实测情况:主链路对话已正常,但「模型管理 → 测试」按钮发出的请求仍然不带会话头,OpenCode Go 用户点测试会全部误报失败。

    环境

    • ZCode 3.11.2.6792(Windows 11,preview 更新通道)
    • OpenCode Go 订阅,自定义 provider(openai-compatible)指向 https://opencode.ai/zen/go/v1
    • 涉及模型:glm-5.3 / glm-5.3-flash / kimi-k3 / deepseek-v4-pro / deepseek-v4-flash / qwen3.8-max / omen-alpha / hy4-preview

    现象

    • 实际对话/推理请求全部正常(连续多日通过 zcode-agent-service 用 glm-5.3-flash 跑会话,无报错)
    • 但模型管理界面里每个模型的「测试」按钮都失败,全部返回同样的 400

    原因(日志实锤)

    testModelConnectivity 发出的探测请求(见 ~/.zcode/v2/logs/)头信息只有这些,没有任何会话标识:

    "headers": {
      "content-type": "application/json",
      "authorization": "Bearer <redacted>",
      "User-Agent": "ZCode/unknown",
      "HTTP-Referer": "https://zcode.z.ai",
      "X-Title": "Z Code@electron"
    }

    网关响应(HTTP 400,9 个模型逐一测试全部相同):

    {"type":"error","error":{"type":"MissingSessionID","message":"Error from provider (Console Go): Request is missing x-opencode-session and cannot be routed efficiently. Please see https://opencode.ai/docs/go/#where-can-i-use-it"}}

    curl 对照实验

    同一请求体、同一 API key,直接打 https://opencode.ai/zen/go/v1/chat/completions:

    请求 结果
    不带 x-opencode-session(复现测试按钮) 400 MissingSessionID
    带 x-opencode-session: sess-xxx 200,模型正常回复

    说明 key、模型、provider 配置本身都没有问题,纯粹是测试路径缺会话头。

    建议

    1. testModelConnectivity 这条探测路径也发送与主链路一致的会话标识(x-opencode-session,或 ZCode 原生会话头),让「测试」结果反映真实可用性——目前测试结果和实际可用性完全相反,对 OpenCode Go 用户有很强误导性
    2. 顺带:测试请求的 User-Agent 是字面量 ZCode/unknown,建议带上真实版本号(OpenCode Go 也要求客户端以自有 UA 自报身份,而不是 unknown)

    TL;DR for the OpenCode folks watching this issue: on ZCode 3.11.2, real inference traffic works fine (the fix or native-header recognition is effective on the main path), but the model-management "test" button sends a bare probe with no session header (UA literally ZCode/unknown) and gets 400 MissingSessionID for every model. Worth accounting for when correlating telemetry — those test-button failures don't mean the client is broken.

  4. 2574862764 commented on Sep 8, 2026

    @2574862764

    所以这个问题怎么解决啊

  5. bisslot commented on Sep 9, 2026

    @bisslot

    opencode go订阅在zcode desktop app v 3.11.2 中无法接入出现调用异常的问题仍然没有解决.
    The issue of a call exception when OpenCode Go subscription cannot be integrated in ZCode desktop app v 3.11.2 remains unresolved.

    @thdxr @liushidai @2574862764 @wangjianjq @tomsun28

  6. liushidai commented on Sep 9, 2026

    @liushidai

    换其他工具吧,zcode太封闭了,很明显glm有做A/的想法,暂时还没有做A/的实力

    官网文档:https://zcode.z.ai/cn/docs/configuration

    目前也不支持为第三方模型追加自定义请求参数:~/.zcode/v2/config.json 中供应商的 options 只识别 apiKey、baseURL、apiKeyRequired、headers 等连接参数,手动加入的其他字段(如 reasoning_effort、vl_high_resolution_images)不会写入请求体,也不会有报错提示。

  7. younguis commented on Sep 9, 2026

    @younguis

    有必要乱搞这些吗,典型的API中转站要各个Agent软件厂来适配它,有点搞笑了

  8. deltacat commented on Sep 9, 2026

    @deltacat

    opencode go订阅在zcode desktop app v 3.11.2 中无法接入出现调用异常的问题仍然没有解决. The issue of a call exception when OpenCode Go subscription cannot be integrated in ZCode desktop app v 3.11.2 remains unresolved.

    @thdxr @liushidai @2574862764 @wangjianjq @tomsun28

    其实可以用, @wangjianjq 描述了,测试不通过,但是实际上会话中是可以使用的。

    另外同意 @younguis ,opencode 搞的这个事情不是zcode的锅。

  9. bisslot commented on Sep 11, 2026

    @bisslot

    opencode go订阅在zcode desktop app v 3.11.2 中无法接入出现调用异常的问题仍然没有解决. The issue of a call exception when OpenCode Go subscription cannot be integrated in ZCode desktop app v 3.11.2 remains unresolved.
    @thdxr @liushidai @2574862764 @wangjianjq @tomsun28

    其实可以用, @wangjianjq 描述了,测试不通过,但是实际上会话中是可以使用的。

    另外同意 @younguis ,opencode 搞的这个事情不是zcode的锅。

    至目前GO订阅GLM-5.3-FLASH在zcode 中会话仍然不支持, 其它GLM-5.2 都正常.

  10. hushenghao commented on Sep 11, 2026

    @hushenghao

    opencode go订阅在zcode desktop app v 3.11.2 中无法接入出现调用异常的问题仍然没有解决. The issue of a call exception when OpenCode Go subscription cannot be integrated in ZCode desktop app v 3.11.2 remains unresolved.
    @thdxr @liushidai @2574862764 @wangjianjq @tomsun28

    其实可以用, @wangjianjq 描述了,测试不通过,但是实际上会话中是可以使用的。
    另外同意 @younguis ,opencode 搞的这个事情不是zcode的锅。

    至目前GO订阅GLM-5.3-FLASH在zcode 中会话仍然不支持, 其它GLM-5.2 都正常.

    检查你的配置信息,这两个模型都是可以在zcode上使用的

  11. daihaowxg commented on Sep 14, 2026

    @daihaowxg

    opencode go订阅在zcode desktop app v 3.11.2 中无法接入出现调用异常的问题仍然没有解决. The issue of a call exception when OpenCode Go subscription cannot be integrated in ZCode desktop app v 3.11.2 remains unresolved.
    @thdxr @liushidai @2574862764 @wangjianjq @tomsun28

    其实可以用, @wangjianjq 描述了,测试不通过,但是实际上会话中是可以使用的。

    另外同意 @younguis ,opencode 搞的这个事情不是zcode的锅。

    已验证,2026-09-14 09:40,测试端点不通过,但实际在会话中使用时是可以正常对话的。

  12. Takina610 commented on Sep 15, 2026

    @Takina610

    虽然接入失败,但是可以正常对话,2026-09-15 09:43

  13. Josephur commented on Sep 15, 2026

    @Josephur

    I am still getting this error today when trying to use my Opencode Go API key within ZCode: Connection failed: Error from provider (Console Go): Request is missing x-opencode-session and cannot be routed efficiently. Please see https://opencode.ai/docs/go/#where-can-i-use-it

    According to https://opencode.ai/docs/go/#where-can-i-use-it the x-opencode-session header is no longer needed anymore, but it sounds to me like it is and ZCode is not passing it?

  14. Dr3ladwyn commented on Sep 16, 2026

    @Dr3ladwyn

    This problem is still unsolved

  15. xuyuan7101 commented on Nov 8, 2026

    @xuyuan7101

    Still entangled with this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions