Repository navigation
fix: key OpenCode 2.x child sessions by their own x-opencode-session-id (#2779) - #2792
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3304-pr.2792.71d9d95This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2792.tgz
npm install -g packageInstall instructions are refreshed on each push. |
3cffa59 to
62a0f88
Compare
[bot] 🏷 PR #2792 复审完成(本 PR 是 #2779 的交付物,此轮按 PR Review 规范对代码与行为做了完整审查,并把分支 rebase 到当前 master)。 ① 原 issue 方向关:#2779 已在 #2779 线程里对照 opencode 2.x 源码( ② 回归审查(逐消费点清点,rebase 后 HEAD 上复核):identity 链的全部消费者逐一过过——
③ 代码审查:核心改动一行(names 数组在 ④ 测试有效性:新测试是真测试——5 个 hermetic e2e(chat/responses/anthropic)交错父+兄弟请求断言三个独立会话(bug 回归时会塌成 1 个,抓得住)+ 上游透传头逐字节断言;单测钉住链序、空头回落、claude/mavis/plugin 优先级。未加 gate,CI 每次必跑。 ⑤ diff 整洁度:7 文件 +152/-6,每一行都与本 PR 目的相关(核心 1 行+注释、hint 字符串、文档、测试),干净。 结构化八问
行为变更披露(old→new):proxy 模式下 OpenCode 2.x 的 subagent/fork 会话:旧 = 按继承父亲和键归并(与父共享 state)→ 新 = 按自身 本轮操作:master 在 PR 开出后前进了 4 个提交(#2781/#2788,均 storage 域,与本 PR 零文件重叠)→ 已 rebase 到当前 master( 判定:代码可合;等新 head 的 CI 全绿后即可合并,合并由人执行。 |
c5daee3 to
51e7e59
Compare
…id (#2779) OpenCode 2.x stamps each model request's OWN session id in x-opencode-session-id while x-session-affinity / X-Session-Id / x-opencode-session all carry the inherited cache-routing affinity (parentID ?? fork source ?? own id). The identity chain read only the affinity-side headers, so a parent and all of its subagent/fork siblings resolved to one conversation key and shared mutable ACP state. Insert x-opencode-session-id into the priority list between x-mavis-session-id and x-session-affinity (client-specific trust class); blank values fall through as before. Upstream headers and cache keys are forwarded byte-unchanged. 1.x traffic is inert (it never sends the header — it stamped its own id into the affinity headers, so this restores 1.x isolation for 2.x); root sessions keep their current key (affinity === own id).
51e7e59 to
5f70fc7
Compare
…ntion) The suite sends anonymous requests whose prefix-affinity chains were persisted into the machine-global stateDir()/prefix-affinity.json, sharing the file with every other un-isolated suite running in parallel on the CI runner. Add the standard XDG_* mkdtemp isolation used by the other e2e suites so the suite stops being a writer to the shared pool.
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.346-master.87060e5 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #2779
Root cause
OpenCode 2.x stamps each model request's OWN session id in
x-opencode-session-id, whilex-session-affinity/X-Session-Id/x-opencode-sessionall carry the inherited cache-routing affinity (parentID ?? fork source ?? own id,packages/core/src/session/affinity.ts). The identity chain inconversationHeaderSourceread only the affinity-side headers, so a parent and all of its subagent/fork siblings resolved to ONE conversation key and shared mutable ACP state.Verified against source:
packages/core/src/session/model-request.ts:278-295(per-request header stamping) +packages/core/src/session/affinity.ts:7-8.v1.15.13,packages/opencode/src/session/llm/request.ts:168-184) stamped its OWN id into the affinity headers and never sentx-opencode-session-id— the change is inert for 1.x and restores 1.x isolation parity for 2.x.Fix
Insert
x-opencode-session-idinto the priority list betweenx-mavis-session-idandx-session-affinity(client-specific trust class; blank values fall through as before). Upstream headers and cache keys are forwarded byte-unchanged; explicit full-plugin identity precedence (x-bili-plugin-conversationunder thex-bili-pluginmarker) is retained.Behavior change (old -> new)
Proxy mode, OpenCode 2.x only: subagent/fork sessions are now keyed by their OWN
ses_id instead of the inherited parent affinity (old: shared mutable ACP state with the parent; new: isolated). Root sessions unchanged (affinity === own id there). 1.x traffic unchanged (header absent). Plugin mode unchanged (plugin-header precedence preserved). No config/env surface change.Tests
tests/proxy-session-id.test.ts: chain-order unit cases (beats the affinity trio; lone header; whitespace-only falls back; claude/mavis/plugin precedence retained).tests/responses-instructions-drift.test.ts: winning-header assertions incl. blank fallback and plugin precedence.tests/e2e-session-identity.test.ts: five new hermetic e2e tests over chat-completions / responses / anthropic — interleaved parent+sibling requests yield THREE independent compression states; upstream-passthrough asserts confirmx-session-affinity/x-session-id/x-opencode-sessionreach upstream unchanged alongside the child's ownx-opencode-session-id; plus blank-header fallback and plugin-precedence tests.Local: targeted suites 50/50 green, typecheck clean, build green. Full suite left to CI.