fix(v1): normalize ref tag placement - #12
Merged
ranxianglei merged 1 commit intoAug 13, 2026
Merged
Conversation
Contributor
Author
Dual-agent review按
复审后的验证: 非阻断剩余风险:尚未运行真实 OpenCode V1 端到端;实现依赖当前 kernel XML ref-tag 格式。V2 明确不在本 PR 范围内。 |
This was referenced Aug 13, 2026
Merged
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.
范围
这是原 PR #2 在当前 monorepo 上的替代版本,仅修复 OpenCode V1 适配器:
packages/billion-context-opencode/src/messages-v1.ts和 V1 system hookmessages-v2.ts,也不对尚未验证的 OpenCode V2 宿主行为作结论现象
PR #1 的就地
splice修复生效后,kernel 渲染的<acp tokens="N" type="text">mNNNNN</acp>会真实进入 V1 模型输入。V1 重组逻辑原样复制这些前缀标签,包括 assistant 历史消息,因此模型会看到自己过去的回复带标签并可能模仿回显。同时,user 标签位于正文行首,会占据正文开头的注意力位置。
修复
对齐
billion-context-pi的成熟实现,仅在 V1 重组阶段处理标签:patchRefTag:assistant 文本保持无标签;user 标签追加到正文末尾rebuildBodyFromCore:当 kernel 改写正文时,使用改写后的正文重建 V1 text part;assistant 改写保留正文但不带标签,空正文改写也不会恢复旧内容peelRefTagText/REF_TAG:只识别 kernel 实际生成的 XML 标签,不把用户正文开头的[m12345]当成旧标签剥除SYSTEM_PROMPT和 V2 hook 均不改ref 分配和
state.messageRefs不变;dual-shape export、持久化状态以及 tool call/result 配对规则均不受影响。验证
[mNNNNN]防回归npm run typecheck:通过npm run test:30/30 通过npm run build:通过仓库现有根目录
smoke.mjs仍引用重构前的dist/index.js,而当前构建输出位于packages/billion-context-opencode/dist/index.js;这是当前master的既有路径问题,本 PR 未扩大范围修改。开发记录与审查
devlog/2026-08-13_v1-ref-tag-normalization/包含REQ.md、WORKLOG.md、DESIGN.mdAGENTS.md要求交由两名独立 Agent 审查;审查结论记录在 PR 评论中