Repository navigation
[PR] fix: demote stale-small usage anchors to the calibrated local estimate in baseline readers (#4383) - #4443
ranxianglei wants to merge 1 commit into
Conversation
…e in baseline readers (#4383) A tiny but real usage-grade sample under the session id (title-gen/probe sidecar) settled into lastUsageGradeTokens blinded every input-baseline reader: the kernel growth reference is a low-water mark (#1595) and rode down to it, so growth stayed 0 and auto-folding was disabled for hours until an unrelated external event. statusInputBaseline and effectiveTokenCount now share one guard: an anchor below 25% of the billing-caliber local estimate of the current outbound send AND superseded by a later main send (contextTokensSource="estimate") is demoted to that estimate — #1595's promised local-estimate fallback. The freshness gate keeps fresh small samples authoritative (#1820 B); anchors above the estimate keep their #1839 precedence; sessions without an estimate or freshness stamp behave byte-identically.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.5330-pr.4443.a732cbcThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4443.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:重复——本 PR(#4443)与 #4413 是同一 issue #4383 的两个在途修复,均 open。 违反「一个 issue 一个 PR」的 loop guard。两者症状与机制家族相同(读侧降级「小而陈旧的 usage 锚点」),但对比后 #4443 更准,三点差异:
建议:保留 #4443、关闭 #4413。 按先来后到本应留 #4413,但它的机制不达根(口径错 + 次出口漏修 + 无量化门),两害相权取 #4443。关不关由你定(agent 不关 PR);若你倾向另一侧,#4443 同样可弃。两者文件重叠(src/session.ts / src/server.ts)在 #4413 关闭后不再构成 rebase 负担。 标签:bug、scope/kernel、p1(缺陷类;核心折叠能力整段停摆 4h07m + 重启不愈合 = p1;修复面是 src 侧压缩决策层,kernel/ 未动;复现场景为通用 relay + 不上报 usage 的 upstream + 同 id 侧车样本,无具体客户端车道证据,不打客户端标签) 本地定向验证已完成:
全量回归以远程 CI test lane 为准(当前运行中),八问结论在其出结果后补发。 |
(ai: vllm-qwen/qwen3.8-27b) CI 全绿,审查完成。 主 CI(ubuntu/windows × node 22/24 × 3 shard 全量测试矩阵)、static gates、全部 e2e 车道(codex/pi/dsh/opencode/ws/registry/image/theorem)、PR Build Artifact 均 success(分支上更早几批 cancelled 是被重跑取代的旧触发,每个 workflow 的最新一次均为绿)。本地定向验证:新套件 6/6、相邻 9 套件 84/86(两红在干净 base fe5ba59 复跑同样失败,确认既有 flake)、typecheck 净。 回归清点(触碰路径的既有行为逐项):
八问:
判定:可合。 方向打到根因(读侧资格判定,不是症状层过滤)、机制覆盖两个出口(含 armFailureShrink 吞并次出口)、测试有牙(边界/负控/e2e freeze-breaker 全钉死)、CI 全绿、diff 干净(4 文件 +254/-5,CHANGELOG 已记行为变更 old→new)。当前 master(fd973ca)上 mergeable=true,可直接合并或先 rebase(behind 的 2 个提交均为 CI 基建,#4441 的 unused-exports 门禁在本 head 上也已绿)。 遗留一件事(上条已述):#4413 是本 issue 的重复 PR,建议由你关闭并保留本 PR——agent 无权关 PR。 |
Closes #4383
问题
同一会话 id 下的一次小而真实的 usage-grade 样本(标题生成/探测等侧车请求,复现中为 4733 tokens)被 settleUsageReport 无条件写进 lastUsageGradeTokens,所有输入基线读者(statusInputBaseline / effectiveTokenCount)原样信任。kernel 的 growth reference 是低水位标记(#1595),跟到该值后 growth ≡ 0、压力带失效——自动折叠整段停摆 4h07m(154 次 nudge 全 idle,pendingT1 106k→284k,零折叠),重启不愈合(锚点持久化在 sessions.stats_json)。#1595 书面承诺的「改用本地估算」兜底在读者里从未实现。
修法
两个共享读者走同一个 stale-small 守卫(src/session.ts 新增导出 staleSmallAnchorFallback):
两个字段都是既有的,无新字段)
⇒ 降级为该估算值(source "estimate")。
新鲜度闸门是关键:纯量级判定会误伤新鲜小样本(#1820 B:真实 usage 样本必须立即压过 post-rebuild anchor)——本地回归实测抓到了这个回归,加新鲜度条件后修复、测试钉死。高于估算的锚点保持 #1839 优先(单向,不复活 ghost class);无估算/无新鲜度戳的旧会话行为逐字节不变(负控测试钉死)。
行为变更(old → new)
配置面
无新增/改名/改语义字段。STALE_ANCHOR_RATIO = 0.25 是代码常量,非配置项。
测试
与在途 PR 的关系
PR #2725(open,#2683)处理相反方向(基线过高/跨模型存活),写侧 retireCrossModelBaselines;本修是读侧量级+新鲜度降级,两者互补。若 #2725 先合入,本分支 rebase 即可(触碰文件有重叠:src/session.ts / src/server.ts)。