Repository navigation
[PR] opencode V2: core-align the msgId header — skip the hoisted leading system run (#6525/#6539) - #6553
Closed
ranxianglei wants to merge 1 commit into
Closed
[PR] opencode V2: core-align the msgId header — skip the hoisted leading system run (#6525/#6539)#6553ranxianglei wants to merge 1 commit into
ranxianglei wants to merge 1 commit into
Conversation
…6525/#6539) The server pins host ids against the POST-HOIST core count (prepare-openai validates ids.length against openaiToCore(parsed).length, which hoists the contiguous leading system/developer run out of the fold space). opencode V2's x-bili-msg-ids header was stamped per WIRE message, INCLUDING the leading system, so its count always exceeded the core count on the openai wire and the pin was rejected (a safe content-derived degrade — but opencode V2 never actually pinned on the openai wire). Core-align the V2 extractor: skip the contiguous leading system/developer run before collecting ids so the header count equals the post-hoist core count. No-op on the anthropic wire (system is a separate field, never in messages); mid-conversation system messages keep their ids; a leading-system-only turn degrades (no empty header). Whole-turn poison contract unchanged.
Contributor
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.9596-pr.6553.79a515fThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6553.tgz
npm install -g packageInstall instructions are refreshed on each push. |
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这是啥
opencode V2 一直在发
x-bili-msg-ids头,但在 openai 协议上从来没真正 pin 住过宿主号——服务端每次都把 pin 拒了(安全降级成按内容摘要)。后果:opencode V2 的会话拿不到稳定宿主身份,fork/继承那条线(opencode V2)一直走不了 msgid 轨。根本原因
prepare-openai.ts用validateMsgIds(ids, msgs.length),其中msgs = openaiToCore(parsed)——内核会把开头的连续 system/developer 段 hoist 出折叠空间。所以 openai 线上msgs.length= 线消息数 − 开头 system 段长度。x-bili-msg-ids头是按每一条 wire message 发的(opencodeV2MsgIdList遍历全部,含开头 system)。于是头里的号数永远 = 线消息数 > post-hoist core 数 →validateMsgIds计数不等 → pin 被拒。一句话:客户端发的号是按「线消息」算的,服务端校验是按「hoist 后 core」算的,openai 线两者差一个开头 system 段,永远对不齐。
怎么修的
src/agent/opencode-v2-msgids.ts的opencodeV2MsgIdList加一处 core-align:收集号之前,先跳过开头的连续 system/developer 段(和内核openaiToCore的 hoist 规则对齐)。这样头数 = post-hoist core 数,pin 就能通过。验证
tests/opencode-v2-msgids.test.ts10/10(原 5 + 新 5 条 core-align 回归:开头段跳过 / anthropic no-op / 中途 system 保留 / 纯开头段→不发 / 开头段后 poison 仍杀)。tests/msgid-pin.test.ts9/9、tests/opencode-fork-adopt.test.ts2/2。tests/opencode-v2.test.ts31/34,3 个失败在 baseline(不含本改动)上同样失败 = 既有环境问题,非本 PR 引入。范围