Repository navigation
[PR] Fix: compression prompt permanently broken — after upstream stopped reporting usage, baseline frozen at stale value, nud | 修复:压缩提示永久失灵——上游停报 usage 后基准冻结在旧值,nudge 4小时不触发 (#4383) - #4413
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.5342-pr.4413.3541d61This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4413.tgz
npm install -g packageInstall instructions are refreshed on each push. |
cfcf2a9 to
1e8e5e9
Compare
1e8e5e9 to
8166568
Compare
|
(ai: zhipuai-lb/glm-5.3) 状态说明:#4383 经核验为存量缺陷(机制在 v0.1.202 与 v0.1.204 逐字节一致),非 203/204 回归。按 owner 决定「非回归问题本版不合并」,本 PR 留待下个版本,保持 open、不阻塞发版。 |
(ai: vllm-qwen/qwen3.8-27b) 复核结论(本轮我独立核对了 CI 与 head 代码;回归分类沿用 floor 4 的逐版本核验,未重跑): ① CI 已转绿。 floor 3 报的 ② 修复完好、单提交干净。 head 为单 commit ③ 维持 owner 决定,现状不变。 「存量缺陷、非 203/204 回归」的判定沿用 floor 4 的逐版本核验(v0.1.202 与 v0.1.204 机制逐字节一致),据此「非回归本版不合」。PR 现 一句话:CI 绿、修复在位、可留待下版——本轮无待办。 |
…wo provably silent cycles
usageAnchorCycleStale only fires while lastInputTokensSource is "usage". An upstream failure arms the per-send estimate into lastInputTokens (source "estimate") without touching contextTokensSource or lastUsageGradeTokens — from that point the predicate is blind and the frozen stale grade resurrects through effectiveTokenCount branch 3 (and statusInputBaseline), re-blinding a healed session on every failure turn. Probe against this head: settle 4733 -> one send -> arm 1,108,494 => both readers serve {tokens:4733} at a real ~300K context. The issue body corroborates: 9 of 11 upstream failures armed estimates up to 1,108,494 yet the nudge kept reading 4733.
New gate gradeAnchorCycleStale: demotes the frozen usage-grade anchor when source is off {usage, overflow-arm} AND at least STALE_GRADE_MIN_SILENT_SENDS (=2) main-lane sends completed since the last settled report. Depth is the only discriminator: #1839 G1 proves a fresh small measurement (fake upstream reporting fixed input_tokens=5000) is field-indistinguishable from a stale sidecar sample by magnitude or by a binary flip, so one silent cycle keeps the anchor authoritative; two completed sends prove the flow is dead.
sendsSinceUsageSettle: new persisted stats counter (incremented in noteOutboundContextEstimates, zeroed in settleUsageReport, cleared at resetSessionCompression, restored with validation; legacy records absent = 0, self-heals within two sends). Overflow-arm authority untouched (#1839). CHANGELOG entry added for the PR.
|
(ai: zhipuai-lb/glm-5.3) 陈旧票清理(第三批动作①):同 issue 有更新 PR [4443]。为避免重复劳动关闭本 PR;如判断有误请直接 reopen 并留言。 |
Fixes #4383
什么坏了(人话)
会话里只要落过一次真实的 usage 上报(比如早期 4733 tokens),之后上游/网关不再回报 usage(有些网关不透传、模型切换后不再带 usage 字段),bili 的"上次实际用量"基准就永远冻结在那个旧值:上下文实际涨到 30 万 tokens,压缩提示的用量却一直显示 1%(4733/750000),增长量算出来是 0,连续 154 个请求 nudge 一次不响,4 小时 0 次折叠,上下文白白膨胀、成本暴涨。#4383 报告者的会话就是这条链:usage 基准 4733 冻结 → growth=0 < 触发门槛 22500 → 压缩能力整体停摆。
根因(机制链)
settleUsageReport(src/cache-ledger.ts)在任何 total>0 的上报时把lastInputTokens/lastUsageGradeTokens标成 usage 级并打上contextTokensSource="usage"。contextTokens/contextTokensSource重新盖成"estimate",只有下一次真实 usage settle 才会翻回"usage"。effectiveTokenCount(src/server.ts:2350)分支一只看lastInputTokensSource==="usage"就直接返回旧锚——它不知道 usage 流已经断了;statusInputBaseline(面板/状态面)同样。于是"最后一次上报时的真相"被当成了"现在仍然成立"。nudge: no-usage recovery leaves stale reference after network or 5xx failure #1595 承诺的"没有 usage 样本时 nudge 骑本地估算"在代码里从未兑现:一旦落过任何一个样本就再也不回退。怎么修的
usageAnchorCycleStale(src/session.ts):lastInputTokensSource==="usage" && contextTokensSource==="estimate"且存在活的每发送估算——在决策时刻(prepare 发生在本轮发送之前)这证明上一个完整周期结束时没有 usage 上报,锚已过期。利用的是现成字段的时间序,不加新字段、不动持久化格式。effectiveTokenCount:锚过期时跳过分支一(usage 锚)和分支三(grade 锚),落到既有 [Bug] 上游从不报告 usage 时 nudge 永不触发——上下文无界增长直到超窗(ChatGPT 登录态后端) #728 路径min(本地发送上界, 当前裸历史估算)(fail-closed 口径,只偏早不偏晚),直到下一次真实上报重新锚定。statusInputBaseline同步镜像(面板不再显示 1% 假象;codex-compact 健康门、循环重建的紧急带恢复视力)。noteOutboundContextEstimates(cache-ledger.ts),行为等价,写入契约可被测试直接钉住。两种压缩模式都覆盖:relay 必经点注释明确 streaming/plugin pipe/非流式全部汇入,插件车道同样盖 estimate 章、同样被 settle 翻回——谓词对两车道语义一致。
测试
新增
tests/issue4383-stale-usage-anchor.test.ts8 项,正反双向(#3617):冻结形状恢复估算、健康周期不误判、上报后恢复锚定、overflow-arm 保持权威、grade 分支同样旁路、无证据时保留旧锚、#728 车道不变、写入契约逐字段钉住。相邻回归 245 项全绿(cache-ledger×5、plugin-nudge-injection、issue1492/1569/1820/1839/2020/2029/2033/2117/2129/2366/3862/3900、fork-nudge×2、codex-compact、silent-backend-nudge 等),typecheck 干净。config surface
无新增配置、无 env、无行为开关。
kernel
不涉及
kernel/(纯 src 侧)。