Repository navigation
[PR] fix(pi-msgids): model-switch rewrite no longer drops client message ids (pairing proof preserved) | fix(pi-msgids): 切模型改写不再丢客户端消息 id(配对证明保留) - #4834
Conversation
A model switch rewrites WIRE bytes (thinking flattened to text, redacted thinking dropped, images downgraded to a placeholder for non-vision targets, tool-call ids renumbered) while the pi session entry id — the message's stable identity — never changes. The walker's exact-equality fingerprint treated every one of those rewrites as a mismatch, so the first turn after a switch dropped the whole msgIds field and fell back to content-derived ids, re-minting identity for messages whose host id had not moved (#4390 D4-1 churn family). Pairing is still proven — role, order, and non-tool part bytes must line up; a dropped/injected message or a real text edit still refuses the field (all-or-nothing). Only pi-stable-ai transformMessages' own transforms (verified against its dist) are tolerated.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6287-pr.4834.6b93423This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4834.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复 —— 按「pi msgIds model switch」与「laneMsgIdsForWire」检索 open+closed issue/PR:仓库唯一匹配条目即本 PR 自身;#4491/#4390 是正文引用的上游关联,不是并行修复。 标签: bug / pi / scope/wiring / p2(理由:切模型后 id 通道整轮降级、身份重铸每次复发,但内容派生 id 回退仍正确可用——有绕行的功能缺陷 = p2,不构成缓存泄漏/不可用级 p1)。 审核结论(独立重审,非复读正文)我做了什么:
代码判定要点(独立推导):
八问
判定:merge-ready(人审合并) —— 代码、测试、回归面均站得住;唯一 CI 红为 windows runner 环境 flake(证据如上),重跑已触发,转绿后无阻塞项。按 §7.4 属身份通道语义变更,不走 auto-merge,留人审合入。 |
(ai: vllm-qwen/qwen3.8-27b) 补一行收口:重跑已绿 —— run 40305442246 整体 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.859-master.8539f78 # this exact build
npm install -g billion-context@master # always the newest merged build
|
…he turn A turn that the guard discards had already claimed its msgIds client-side (all-or-nothing, #4491). The burned ids were never released, so the host's retry of the same turn lost the whole msgIds field and the server pinned those rows to content-derived identity — the exact host/server divergence #4834 just fixed, self-inflicted here by the client lanes themselves. Hoist the #3370/#3378 single-flight guard above planIncrementalTurn in both native lanes (dsh, omp). The guard only reads the pending-ack table, so the reorder changes nothing for the guard itself; planning now only happens for turns that will actually be dispatched. Regression test: a guard-blocked delta attempt must not burn its ids — after the seed acks, the retry still pins msgIds (pre-fix: the field is silently dropped).
…glei#4491/ranxianglei#4834) The doctrine said stable client ids may only ever be join hints. That was written before the plugin lanes started shipping host msgids in a bili-private envelope (msgIds on the incremental turn / biliMsgIds stripped at ingress) and before ranxianglei#4834 made resolution id-first. Agents reading the docs concluded 'we have no msgids' — true on the model wire, false on the plugin lanes. - AGENTS.md KDD ranxianglei#11 retitled to the full hierarchy: msgid first where the envelope carries it (plugin lanes only, never forwarded upstream), order still primary on id-less resend reconciliation, hash stays the per-cell gate. Three-part PK (session_id, msg_id, content_hash) noted as safety belt. - AGENTS.md KDD ranxianglei#13 evolution updated to four stages (hash -> order -> msgid pinning -> snapshot render). - MESSAGE-IDENTITY.md: new section 'The msgid envelope' documenting the channel, all-or-nothing semantics, resync re-claim, ranxianglei#4834 id-first, ranxianglei#4863 claim-after-guard, and the boundary (model wire unchanged, tool-call ids are pairing keys, proxy-mode resends keep the ladder); Future-direction paragraph refreshed.
这是啥问题
pi 切换模型后,历史消息的线上字节会被 pi 自己改写(thinking 块拍平成 text、redacted thinking 整块丢弃、非视觉模型把图片降级为占位文本、工具调用 id 跨模型规范化),但会话条目的 id 没变。旧版
laneMsgIdsForWire指纹逐字节严格相等,任何一处改写都判"对不上"→ 整轮丢掉 msgIds 字段 → 退回内容派生 id → 账本为 id 从未变过的消息重新铸造身份。这正是 #4390 D4-1 一类"身份重铸"打地鼠的开关源头:每次切模型必复发。根本原因
src/agent/pi-msgids.ts的锁步配对把"pi 自己的合法转换"和"真的对不上"混为一谈:n.parts.length !== wParts.length || n.parts.some(...)逐字节严格比较,thinking→text(块数不变但类型变)、redacted 丢弃(wire 少一块)全都 fail。改动
partsLowerThrough:双指针配对,仍然证明角色、顺序、非工具部分的字节相等;只放行 pi-stable-aitransformMessages自己的转换集(对照其 dist 逐条验证):think↔ wiretext(同文本)redact跨模型被丢弃img↔ wire 占位文本(image omitted: model does not support images),连续图片坍缩到同一占位符tooluse/toolres跨模型 id 规范化漂移(pin 的是 entry id,值漂移不入账本)为什么这样做(设计取舍)
宿主 id 是消息的稳定身份;切模型改的是字节不是身份。字节改动不该否决 id——否则 id 通道形同虚设,身份永远被字节 hash 绑架(打地鼠之源)。本 PR 只改"配对证明的放行集",不动统一账本的主键/世代判定(同 id 新字节仍走世代行,引用不撒谎)——"id 是否当主键"另议。
验证
tests/pi-msgids.test.ts11/11tsc --noEmit干净关联:#4491(id 通道)、#4390 D4-1(身份重铸事故)、#3752(编解码升级漂移)