Repository navigation
fix: stamp x-opencode-session on OpenCode Go external summary requests (#2760) - #2761
ranxianglei wants to merge 1 commit into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3029-pr.2761.3979f6fThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2761.tgz
npm install -g packageInstall instructions are refreshed on each push. |
#2760) OpenCode Go (/zen/go) rejects independent summary calls lacking a stable x-opencode-session header (HTTP 400 MissingSessionID). The external-summary path built only auth headers, so Go targets always failed. Thread the session id through both plan-build sites (the compress-tool lane covers plugin+proxy modes; the preflight/auto-fold lane covers growth folding) and stamp x-opencode-session plus bili's own user agent at request generation for explicit Go targets only. It is derived from bili's own conversation id, never copied from the client's inbound session/auth headers. Non-Go targets and legacy preflight are untouched. Adds WC-016 to the wire-constraint ledger as a header rule with a validation-parity fake and BOTH-modes regression tests.
bdf4266 to
8c15f4b
Compare
[bot] 🏷 PR #2761 Review 结论(结构化八问)先说结论:代码方向正确、改动最小、双压缩模式都覆盖、测试扎实;我已顺手修掉唯一挡 CI 的缺陷(内部类型多了一个 ① 是什么问题:OpenCode Go 的外部摘要请求没带 ② 什么原因导致的:出站摘要候选 ③ 影响范围与严重程度:仅影响配置了 OpenCode Go 外部摘要目标、且摘要链路命中 ④ 怎么修复的:把会话 id 从两个压缩入口(compress-tool 通道用 ⑤ 是否有回归问题(逐项过既有行为):
⑥ 是否破坏缓存:不涉及。只在 Go 摘要出站请求上加头,不改客户端可见请求/重建、不改进持久化历史、不改 ⑦ 是否改了设计方向:不涉及架构转向。按既有 wire-contract ledger 模式新增一条 WC-016( ⑧ 是否引入新配置:不涉及。无新 env / config / CLI flag / 默认值;只复用已存在的 session id 与既有 关于「上游 PR 冲突(merge state: dirty)」通知 —— 我核实后没有执行 rebase / force-push我用官方 API 核对了真实状态,与通知描述不符:
本地验证证据(针对含修复的分支内容)
收工判定特性本身可合(§7.4:因它改动双压缩模式的出站 wire,不满足自动合并条件,需你人工 review 后合并)。当前无需任何额外动作来解除合并(GitHub 判定 mergeable);CI 绿了直接合并即可。若你希望把分支钉到最新 master 顶端,那是可选的,建议由你本人完成或用普通 merge(非 force-push)。 |
isOpenCodeGoTarget matched any /zen/go* prefix, so a hypothetical /zen/golang endpoint would also get the x-opencode-session stamp. Match exactly /zen/go or /zen/go/... and pin the boundary with tests (#2761 review, minor 1).
Closes #2760
Summary
OpenCode Go (
opencode.ai/zen/go) rejects independent summary calls that lack a stablex-opencode-sessionheader withHTTP 400 MissingSessionID. bili's external-summary path built only auth headers (authorization/x-api-key/x-goog-api-key) before handing off tocreateSummaryHttpCandidate, which deliberately carries none of the main request's session headers — so a Go summary target always failed (candidate outcomeerror, batchfailed/exhausted).This fix threads the conversation id through both plan-build sites and stamps the required header (+ bili's own user agent) at request generation for explicit Go targets only.
Changes
src/external-summary-http.ts:SummaryHttpTargetgains optionalsessionId; newisOpenCodeGoTarget()(hostopencode.ai+/zen/goprefix, so the zen Anthropic proxy under/zen/v1is untouched); when the target is Go and a session id is present, stampx-opencode-session+user-agent: billion-context/<version>.src/external-summary-runtime.ts:ConfiguredSummaryPlan/configuredSummaryPlanacceptsessionIdand pass it to each candidate.src/external-summary-compress.ts(compress-tool lane — covers BOTH plugin & proxy modes) andsrc/preflight.ts(preflight/auto-fold lane) pass their session id into the plan builder.tests/wire-contract-fakes.ts(+validateGoSessionHeaders, exactgoMissingSessionIdEnvelope), self-check extension intests/wire-contract.test.ts, and a dedicated BOTH-modes regression suitetests/wire-contract-go-session.test.ts.Behavior change disclosure (policy 2026-09-22)
HTTP 400 MissingSessionID; the batch reportedfailed/exhaustedand nothing was compressed.x-opencode-session(= bili's own stable conversation id) anduser-agent: billion-context/<version>.opencode.ai/zen/go/*summary endpoints. Non-Go targets, the main relay wire, acp_summary carriers, and legacy preflight are byte-for-byte unchanged (pinned by the existingexternal-summary-http.test.tsno-session-header assertions + a new off-Go guard test).session.id, never copied from the client's inbound session/auth headers — no client credential or identity is forwarded to the third-party endpoint.Config surface
No new config field, env var, or CLI flag. The fix reuses the already-resolved session id riding the request; the
externalSummarysettings schema is untouched. Nokernel/changes.Review note
This changes outbound request shape on a both-modes path (compress-tool + preflight/auto-fold), so per §7.4 it is not auto-mergeable — human review requested. Verified locally on the rebased head: typecheck ✓, build ✓, targeted suites green (WC-016 gates, external-summary-http, external-summary-runtime, wire-contract = 76 tests). Full suite + codex e2e left to CI.
结构化结论(八问)
x-opencode-session会话头,被上游以HTTP 400 MissingSessionID拒绝,导致该目标下所有摘要失败、无法折叠。createSummaryHttpCandidate设计上不携带主请求的任何 session 头,而摘要调用链上也没有传递 conversation 身份——Go 端因此拿不到路由所需的稳定会话头。(stream 与否与此无关,实测 stream=true 同样 400。)opencode.ai/zen/go」的用户;此场景下摘要功能完全不可用(每次 400)。其他协议/上游、主模型转发、acp_summary 载体均不受影响。x-opencode-session(取 bili 自己的session.id)+ bili 自己的 user agent。非 Go 目标与旧 preflight 路径零改动。x-opencode-session只是发往 Go 的路由键值,不参与 bili 内部任何缓存/去重/游标键;seenCandidateWarnings去重与执行器重试/failover 逻辑均未改动。判定:改动最小且机制单一,已按 #1304 入账(WC-016 + validation-parity fake + BOTH-modes 回归),本地定向验证全绿;因属双模式出站 wire 变更,按规范需人工 review 后合并。