Repository navigation
[PR] fix: image recovery — one ref per split image, DSH attachments recoverable (root-cause: image-recovery-spill) - #6902
ranxianglei wants to merge 4 commits into
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.11019-pr.6902.51330ceThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6902.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 本 PR 是 image-recovery-spill 根因家族的指定唯一聚合 PR(#6894, Review of the aggregation PR — GitHub #6902, head Cherry-pick fidelity (verified, not taken on faith).
Head Facet 1 (#6851, host) — verified. The bug is real: the Responses codec ( Facet 2 (#6875, kernel) — verified. The bug is real (the reporter confirmed the codec-layer direction in #6875: 「之前一直以为问题在 hasUnrecoverableMediaPayload 那一层,方向错了」): DSH
Message-ID stability verified: the tool core id is Local verification (all on the PR head): typecheck clean, build clean; 42 host ( CI: the wave on Existing-behavior audit (regression review):
One open risk (not resolvable from this environment): upstream acceptance. Aggregation requirements (#6894): all met — single root-cause PR, Verdict: mergeable. The code is correct, the tests are strong (both gate directions, migration repro, byte-identical negative cases), CI is green on the identical tree, and the diff is clean (11 files, every line on-purpose). Two human-side notes: (1) the kernel change is human-only review tier (Kernel Boundary rule 3) — the merge is yours either way; (2) if a real DSH session 400s on the re-emitted part, trimming the re-emission post-merge is a clean fallback — the foldability fix does not depend on it. Post-merge: #6854 and #6879 become redundant (owner closes); the reporter can confirm the stale-BLOCKED migration on their session (the 836 rows should migrate to fresh refs on the next fold pass). 中文八问
判定:可合并。 代码正确、测试扎实(双向门、迁移复现、逐字节负例)、相同树上 CI 绿、diff 干净(11 文件,每行都在目的内)。两点人工侧提示:kernel 变更属人工评审档(Kernel Boundary 规则 3),合并权在你;若真实 DSH 会话对重发射的部件返回 400,可后续裁掉 |
DSH read_image results carry {type:"image", attachment:{attachmentId, ...}} in tool results. Two gaps stacked: the codec reduced tool results to text so the part never reached a CoreMessage, and extractMediaRefs never enumerated the shape so the message pinned forever. This lands both halves together: the tool branch preserves attachment-carrying image parts (and re-emits them), the classifier reads attachmentId as a durable re-access handle, and the drop detector stops counting preserved parts as dropped. Already-BLOCKED history migrates via the existing #2607 mechanism on the next compress.
(cherry picked from commit 0e8b779)
…d run) The main CI workflow's runs were cancelled by the pull_request concurrency group before any jobs started (0 jobs), so the full test lanes never ran. This empty commit triggers a fresh synchronize event to re-run them.
e907528 to
0bf0e24
Compare
…00 -> 0.0.201) Master advanced its kernel version past this PR's bump (0.0.198->0.0.199) to 0.0.200 (commit b805e43 resolved the same 0.0.199 collision with #7252). This PR's kernel/src changes (media-refs.ts, openai.ts for #6875) are new work not in any released version, so the merged tree bumps the kernel version to 0.0.201 (master's 0.0.200 + 1) to satisfy the Kernel Boundary version discipline (kernel/src changed => version must advance past the base). The only conflicts were the three version fields (kernel/package.json, kernel/package-lock.json, root package-lock.json). All code files merged cleanly: the PR's first commit (image-restore, #6851) is already in master as fb7047c (identical change), and the PR's kernel files are disjoint from master's kernel changes. kernel-change: recognize DSH attachment refs as recoverable media (#6875) - version bump to 0.0.201 is the mechanical consequence of merging master ahead of this PR's kernel work.
(ai: vllm-qwen/qwen3.8-27b) Merge conflict resolved — PR is now mergeable. I merged What conflicted and how I resolved it:
Note for the reviewer: the PR body's "kernel 0.0.198 → 0.0.199" line is now stale — the effective bump is 0.0.198 → 0.0.201 (master consumed 0.0.199/0.0.200 in between). I did not edit the PR body (out of scope for this lane); flagging it here. Local verification: version consistency confirmed across all three files, no leftover conflict markers, PR kernel changes + master changes both present, merged diff vs master = exactly the PR's kernel commit. A local 结构化八问
判定:冲突已解决,PR 现 |
Root cause: image-recovery-spill
One root cause, two facets — bili's image-media recovery path either
over-recovers (restores sibling images it was never asked for, spilling
quadratic files) or under-recovers (treats a durable, re-fetchable image
handle as unrecoverable and pins the message forever). This PR fixes both so a
single image ref recovers exactly its own image, and a DSH attachment stops
being permanently pinned.
Facet 1 — #6851: Responses split image refs restore sibling images + quadratic spill files
A multi-image Responses user item is split into one core image per ref, but
each split image's
rawResponsesItemstill carries the FULL original item.The host recovery index (
src/image-restore.ts) then bound every split ref toevery image in that carrier: for N images,
N × Nspill files, anddecompressing one ref restored all N siblings (cross-image contamination).
Facet 2 — #6875: DSH
read_image/screenshot attachment permanently BLOCKEDA DSH
read_image/screenshot tool result carries its image as{type:"image", attachment:{attachmentId}}in the content array. The codec(
openaiToCore) reduced tool results to text only, so the attachment neverreached
CoreMessageandextractMediaRefscould never see it — the messagelooked like plain text while its media was invisible. The classifier then
pinned it as unrecoverable media (
BLOCKED) and it could never fold. Thereporter's session had 836 such stale BLOCKED rows (~160K tokens) that never
migrated.
Fix
(
messageImageBytes) returns only the split image core's OWN sidecar whenmm.imagePart === true(remote-only →[]); unsplit carriers and tooloutputs keep the full carrier. N images → N spill files; each ref restores
exactly its own image.
attachment-carrying image parts on tool results into the
rawOpenaiContentPartssidecar (isDshAttachmentPart);extractMediaRefsrecognizes the
attachmentIdas a durable content-addressed handle (bare-idparallel to a DeepSeek
file_id);coreToOpenaire-emits the parts. Thecodec and enumeration land together (a sidecar without enumeration would
newly pin messages — the Image messages become permanently BLOCKED and can never be compressed(DSH
attachmentstructure not recognized)图片消息永久变成 BLOCKED、无法压缩(attachment 结构未被识别) #6875 trap). The message ID is unchanged (refstability). No usable id → keeps pinning (conservative).
Both commits cherry-picked with
-x(authorship preserved).Verification
image-restore,fix-1205) + 13 kernel(
issue6875-*) + 69 kernel (issue5620,issue3939,protected-*) = 124 passkernel-change: recognize DSH attachment refs as recoverable media (#6875) —
the codec preserves attachment-carrying image parts on tool results into the
rawOpenaiContentPartssidecar,extractMediaRefsenumerates theattachmentIdas a durable handle, andcoreToOpenaire-emits them; messageID unchanged (ref stability).
Fixes #6851
Fixes #6875