Repository navigation
[PR] fix(#5620): name never-foldable media mass in acp_status (MEDIA FLOOR) - #5619
ranxianglei wants to merge 4 commits into
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.8046-pr.5619.5c061dfThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5619.tgz
npm install -g packageInstall instructions are refreshed on each push. |
dsh sessions dominated by remote-URL / file-ref images climb to ~70% usage while the kernel offers only tens of K of foldable mass: such messages can never fold (#1188/#2609) and turn integrity pins the turns around them (#684). The PRESSURE NOTE cannot fire in exactly this state — its maxPending < growth-step condition fails because pinned turns keep a range advertised forever (log: maxPending >= 50K while idle reasons show 'growth N < floor 22500') — so users saw a stuck context with zero visibility into why. acp_status (full view) now renders a MEDIA FLOOR line after the PRESSURE NOTE whenever >= 1 live message carries unrecoverable media (kernel predicate hasUnrecoverableMediaPayload) AND their mass is >= 5% of modelContextLimit (MEDIA_FLOOR_REPORT_FRACTION): count, token mass, share of the window, and why the floor does not come down. Additive-only: no existing section, default, threshold, timing, or wire shape changes; no config surface added.
The gate as submitted measured media mass with the local text meter only — openai-wire image parts ride a "[image]" placeholder in CoreMessage.text (kernel/src/wire/openai.ts), so each remote-URL image counted ~2 tok against its billed cost and the 5%-of-window gate was effectively unreachable in exactly the sessions this line exists for (#5620: dsh at ~70% usage dominated by remote images). Add the billed-grade prior the billing lane already uses for images whose bytes bili never sees: REMOTE_IMAGE_TOKENS (src/image-tokens.ts, 4096) per remote-URL image payload, mirroring the media branches of hasUnrecoverableMediaPayload over the sidecar shapes reachable in ctx.messages (openai content/parts, anthropic block/tool_result url-source, responses input_image). Other unrecoverable payloads (file refs, Google fileData/videoMetadata) keep counting toward the message count only — no stable billed prior exists for them. Tests: row A now uses realistic caption-sized fixtures and pins the billed prior in the rendered line; row C re-anchors on 1 remote image ≈ 4096 tok = ~2% < 5%. Typecheck clean; targeted suites green locally, full suite rides CI.
6d839f5 to
f90bb0e
Compare
[bot] 🏷 查重: 不重复 —— 本 PR 是内部 #5620 决策评论中 option C(可观测性)的实现,open/closed 检索无其他 MEDIA FLOOR / media-mass status 相关条目或并行 PR。 审核结论:发现一个真问题,已直接在 PR 分支修掉,并 rebase 到当前 master发现的问题(提交版缺陷):门槛的量程装错了表。 修复(独立标注 commit f90bb0e):按计费层既有约定补上计费级先验——每个远程 URL 图片 payload 加 行为变更披露(相对提交版,不是相对 master):MEDIA FLOOR 行的 验证:typecheck 干净;tests/issue5620-media-floor-status.test.ts 4/4(行 A 改为真实 caption 形态并钉住 ~6% 与 4096 字样;行 C 重锚为 1 张远程图 ≈2% 静默);相邻 acp_status 套件(acp-status / issue2366-cjk-billed / issue4331-uncovered-history / dead-ref-range-filter / issue2432-breaker-awareness)合计 43/43 绿。全量回归交 CI。 基线处理:PR 原分支基于 10-28 的旧 master,落后约一周(~229 文件漂移,含 src/acp-status.ts 自身的 #5139/#5221 改动)。已 rebase 到当前 master 9dc4c94(无冲突;MEDIA FLOOR 区块与 master 新增的 else 提示分支、RESOLVER WEDGE 段互不干扰),rebase 后 typecheck + 全部定向测试重跑通过,已 push(force-with-lease,head=f90bb0e30)。旧 head c18ebcd 的全量 CI 曾为绿(镜像缓存可查);新 head CI 运行中。 八问
判定:方向正确,实现(修复后)成立,测试双向齐全(#3617 纪律:正例 + 可归档负例 + 亚阈值负例 + 增量行)。新 head CI 转绿即可合并;合并留给人。 |
[bot] 🏷 CI 跟进(新 head f90bb0e):静态门禁全绿(static-gates / gate / lock-sync / unused-exports / plan / test-import-graph / config-surface-guard / docs-sync / lifecycle-ledger-guard / pi-subagents-guard / mysql-contract),测试分片(ubuntu/windows × node 22/24 共 12 片)排队/运行中,目前零失败。分片跑完转绿即可合并;若某片红了我会被唤醒继续排查。 |
…tx.messages (review)
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
方向(① 原 issue):#5620 的根因链成立——远程 URL / 文件引用媒体按设计永远不可折叠(#1188/#2609),turn integrity 又把跨越它们的整个回合钉住(#684),残段又低于 50K 折叠门槛,于是会话停在 ~72% 而只有几十 K 可折。本 PR 交付的就是该 issue 里承诺的选项 C(纯观测、零行为变更),范围精确;根治选项 A/B/D 留在 issue 线程等 owner 拍板,正确地没有混进来。无 kernel 触碰。
回归清点(②)——diff 只碰 src/acp-status.ts(+新测试文件),逐项过其承担的既有行为:
- 全量视图输出在门槛未触发时:逐字节不变(单一受门控的
extra.push;测试 D 行钉死「无媒体时不出现新区段」); - scope 视图:
if (scope) return toolOk(base)(src/acp-status.ts:274)先于 extra[] 构建返回,不受影响; - processTurn 失败降级:MEDIA FLOOR 与 Nudge/PRESSURE NOTE/ranges 在同一 try/catch 内,同等降级为 base-only;
- Nudge 与 PRESSURE NOTE 门控代码:未触碰;
- 成本:每次 acp_status 多一次 O(n) 谓词扫描 + 仅对命中消息做 token 计数——低频诊断工具调用,可忽略。
行为变更披露:全量视图acp_status在不可恢复媒体质量 ≥ 窗口 5% 时新增一行信息性输出(PR 正文已声明,additive observability)。其余一律不变。
代码(③):计数器镜像 hasUnrecoverableMediaPayload(kernel/src/protected.ts:609-716)的媒体分支,我逐形状核对了可达性——openai rawOpenaiContent/rawOpenaiContentParts 由编解码器构造上互斥(kernel/src/wire/openai.ts:170-241),else-if 不会漏计;anthropic block / tool_result 嵌套、responses input_image 分支与内核谓词一致;inline-data 正则与内核 isInlineDataUrl 逐字节相同。计费级计量(f90bb0e30 评审修复)用的正是计费车道对远程图实际收费的 REMOTE_IMAGE_TOKENS(src/image-tokens.ts:31、:193-199),口径一致。
测试(④):断言有牙——A 行在无计费先验时会直接失败(恰好钉住 f90bb0e 修的那个缺陷);B/C 是真正的负例(可归档 data:URL、低于阈值);D 钉 additive-only。发现一个覆盖缺口并已顺手补上(见下)。
已顺手修(本分支两个独立 commit,均不触语义):
- src/acp-status.ts:128 原注释称 system sidecar 分支「cannot fire here」——不准确:会话中途的 system 消息带着 rawAnthropicMessage sidecar 留在 core 数组里(kernel/src/wire/anthropic.ts:114-124),谓词的 system 分支可以命中(计入 count、不加图片先验——行为本就正确,只是注释与事实不符)。修正于
261174a6d。 - 计数器的 anthropic / responses 线型分支原先无测试覆盖,补 E/F 两行正例钉住(
7d56a01f6)。本地验证:6/6 通过、tsc 干净;CI 在新 head 重跑中。
结构化八问:
- 是什么问题:dsh 会话里带远程图片的消息永远无法折叠,把上下文地板顶到 ~72%,acp_status 却只报「可折叠范围很少」——用户分不清是压缩器坏了还是结构性地板。
- 什么原因导致的:三层机制叠加——远程媒体按设计不可恢复(#1188/#2609)+ turn integrity 钉住跨媒体回合(#684)+ 残段低于 50K 门槛使 nudge 恒 idle;且此前没有任何诊断面命名这块质量。
- 影响范围与严重程度:所有携带不可折叠媒体的长会话(dsh 截图类工作流最典型);体验瑕疵级——功能可用,但诊断缺失导致误判。本 PR 只加观测,不改任何折叠行为。
- 怎么修复的:acp_status 全量视图中,当不可恢复媒体质量 ≥ 窗口 5% 时输出一行 MEDIA FLOOR:消息数、计费口径 tok 数(文本估算 + 每远程图 REMOTE_IMAGE_TOKENS)、占窗口百分比、成因引用(#1188/#2609/#684)与唯一出路(减少此类图片或开新会话)。
- 是否有回归问题:无。上节逐项清点全部保持;高危模式(语义漂移/fail-fast 变吞错/阈值时序格式漂移)逐项过——唯一的输出变化就是声明过的新增行。
- 是否破坏缓存:不涉及——不改任何出站字节、账本、游标或缓存键。
- 是否改了设计方向:不涉及——A/B/D 根治选项仍在 #5620 待 owner 决策;本 PR 是既定的观测选项 C。
- 是否引入了新的配置:不涉及——无新 env/config/默认值;5% 是模块内常量
MEDIA_FLOOR_REPORT_FRACTION,与相邻的PRESSURE_NOTE_USAGE_FRACTION同风格。
结论:APPROVE —— 方向与既定选项 C 一致,回归清点干净,测试有牙并补齐线型覆盖;两处小问题已在本分支顺手修掉(261174a6d、7d56a01f6),无阻塞项。
Review 完成:GitHub PR #5619(MEDIA FLOOR 观测,#5620 选项 C)判定 APPROVE——方向与既定选项 C 一致、回归清点干净(门槛未触发时输出逐字节不变、scope 视图与降级路径不受影响、无缓存/配置面变化)、测试有牙(A 行恰好钉住 f90bb0e 修的计量缺陷)。GitHub 禁止同账号自批,故以完整 review 评论载体发布判定(含八问)。 |
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
新 head 7d56a01 复核(re-trigger):与上轮已审 head f90bb0e 的增量 = 且仅是本审核自己顺手修的两个 commit(261174a6d 注释修正、7d56a01f6 测试行 E/F),git diff --stat f90bb0e30..origin/2026-11-04_media-floor-status 核实:src/acp-status.ts 仅注释 5+/4-,tests/issue5620-media-floor-status.test.ts 纯增 41 行;无第三方推送。两 commit 推送前已本地验证(该文件 6/6 通过、tsc 干净)。完整评审与八问见上一条 review 评论,判定不变:APPROVE。CI:镜像缓存最近一次读取(fetched_at 2026-11-03T17:58Z)显示 7 success / 11 skipped、12 个 test shard 在跑、零非通过项——按惯例不轮询 gh,以该 head 的 CI 收敛为准。
ranxianglei
left a comment
There was a problem hiding this comment.
Review 结论:当前对 master 可合并(CI 35/35 绿、MERGEABLE),但有一个必须知道的前置依赖。
设计本身扎实:独立门槛正确(PRESSURE NOTE 的 maxPending < nudgeGrowthTokens 在媒体墙会话里结构性永不满足,已复核 master @ 5dee485 src/acp-status.ts:278);billed-grade 计量(REMOTE_IMAGE_TOKENS prior)补掉了本地文本计量只看 [image] 占位符(~2 tok)永远够不到阈值的坑——正是这条报告存在的场景;正负例成对(#3617 纪律)。
顺序耦合(实测):我把它的新测试原样叠加到 #5629(kernel 根治,谓词翻转)的 head 上运行:3 pass / 3 fail。原因:它的阳性用例假设"远程 URL 图片永远不可折叠"(旧谓词),#5629 之后这类消息可折叠,MEDIA FLOOR 不再触发。结论二选一:
- 推荐:#5619 先合(#5618 是进行中事故,观测能力先行有价值;此时它完全自洽),#5629 随后;
- 若 #5629 先落:#5619 需 rebase 并把阳性行改钉真正无句柄的形状(
{type:"mystery"}opaque、document 块、videoMetadata-only),同时重新审视REMOTE_IMAGE_TOKENS计量的稳态意义(被识别的远程图家族都会变可折叠)。
两条非阻塞观察:① 报告文案 "these can never fold (#1188/#2609)" 在 #5629 落地后自动变为精确(语义收窄为真·不可恢复质量),无需改动;② mediaFloorMass 每次 acp_status 全量扫消息,O(n) 轻量,无性能问题。
Part of #5620 — observability option C from the decision comment in that thread. Root-fix options A/B remain pending owner decision there.
Problem
A dsh session dominated by remote-URL / file-ref images climbs to ~70% usage while the kernel offers only tens of K of foldable mass: such messages can never fold (#1188/#2609) and turn integrity pins the turns around them (#684). The existing PRESSURE NOTE cannot fire in exactly this state — its
maxPending < growth-stepcondition fails because pinned turns keep a range advertised forever (in the #5620 log maxPending stayed >= 50K while every idle reason readgrowth N < floor 22500). The user sees a stuck context with zero visibility into why.Change
src/acp-status.ts: new MEDIA FLOOR section after the PRESSURE NOTE. When >= 1 live message carries unrecoverable media (kernel predicatehasUnrecoverableMediaPayload) AND their mass is >= 5% ofmodelContextLimit(MEDIA_FLOOR_REPORT_FRACTION, named constant besidePRESSURE_NOTE_USAGE_FRACTION), full-viewacp_statusreports count, token mass, share of the window, and why the floor does not come down.Behavior change disclosure
Additive-only: one new informational line appears in full-view
acp_statusoutput, only when the gate fires. No other output, default, threshold, timing, or wire shape changes. No config surface added.Tests
New
tests/issue5620-media-floor-status.test.ts, 4 rows per gate discipline (#3617): positive (remote-URL image mass above threshold), negative (archivable data:URL images fold normally, #2607), negative (sub-threshold mass stays silent), additive (media-free sessions keep today's output). Typecheck clean, targeted suites green locally; full suite rides CI.