Repository navigation
fix: re-anchor nudge cadence when count drops below the shown reference - #479
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)In your adapter project: npm install acp-kernel@pr-479Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf acp-kernel-pr479.tgz
npm install ./packageThis comment is automatically updated on each push. |
…ce (#478) nudgeNode's downward reset only compared tokenCount against the baseline, while decideNudge keys growth to lastNudgeShownTokens whenever it is non-zero. An estimate-grade overshoot pinned far above the baseline dead-zoned every growth-gated inject in [baseline - interval, shown + floor) until context regrew past the phantom level or a compression success zeroed the refs (production incident: billion-context#1595). Extend the reset condition to also fire when tokenCount drops below lastNudgeShownTokens - nudgeGrowthTokens, re-anchoring baseline/shown/ per-tier stamps at the settled level. Pure fix: no state-shape, wire-format, or node-ordering change; pressure/emergency bands bypass the growth gate and are untouched.
b463942 to
a587c0c
Compare
[bot] 🏷 Review 完成(按 PR Review 规范逐关过了一遍)。结论:代码修复正确、测试有牙、diff 干净,CI 已全绿,可合并。合并操作留给 owner。 ① 原 issue(#478)方向关根因成立且已在代码级复核: ② 回归审查(既有行为清单)
③ 代码审查
④ 测试有效性我独立验证了「先红后绿」:把新回归测试单独放到未打补丁的 master(5d7b538)上跑 → 失败,断言 ⑤ diff 整洁度 + CI当前 head 关于首轮 CI 失败( 自动合并门槛(§7.4)评估七条全满足:单节点 scope、纯回归测试先红后绿、rebased head 四门全绿、不触碰 §7.3 契约与结构约束、纯 中文摘要:审核了 nudge 下行重置重锚定修复(#478)——方向正确(修根因而非治标)、既有行为逐项清点无无意回归(新子句严格扩宽触发面且已披露)、回归测试经我独立验证在未打补丁 master 上确实报红(9000≠10000)修复后转绿、CI 首因是 master 后落地的 prettier gate 与 PR 旧式测试块冲突,现已 rebase+格式化并在 a587c0c 上全绿,可以合并。 |
Root cause
nudgeNode's downward reset compared the incomingtokenCountagainst the baseline only:but
decideNudgekeys growth tolastNudgeShownTokenswhenever it is non-zero (src/compress.ts:1689). When the two diverge — an estimate-grade reading stamped at inject time that later settles far lower (network-failure local estimate), a model/provider switch, or compaction elsewhere — real counts settling near the low baseline produce permanently negativegrowthSinceReference. Every growth-gated (non-pressure) tier inject then requiresgrowthSinceReference >= growthFloorforever: the cadence dead-zones in[baseline - interval, shown + floor)until context regrows past the phantom level or a compression success zeroes the refs.Production incident: billion-context#1595 (0.1.166/0.1.167) — inject stamped
shown=500733(estimate-grade, 184% of a 272k window); real usage settled at 121k–196k vs baseline ~135k; idle turns showedgrowth=-379112/27000 (ref=500733)indefinitely.Fix
Extend the reset condition to the reference the growth decision actually uses — keep the existing baseline clause, add the symmetric shown clause:
A sustained real drop below the stale shown reference now re-anchors the cadence trio at the settled level instead of blocking it. Note the issue's alternative variant (
min(baseline, shown)) does not cover the production repro:min(135298, 500733) − 27000 = 108298 < 121621, so that clause would never have fired in the incident.tokenCount < lastPerMessageNudgeTokens − nudgeGrowthTokens. WithlastNudgeShownTokenspinned above the baseline, gentle-nudge cadence stayed dead until usage regrew past the phantom shown level or compression succeeded.tokenCount < lastNudgeShownTokens − nudgeGrowthTokens, even if still abovebaseline − interval. Effect: after an overshoot-grade reading, provider switch, or scale change, once real usage settles below the stale reference minus one growth interval, baseline/shown/per-tier stamps re-anchor immediately and growth-gated nudges can fire again after normal regrowth.Evidence (rebased head
a587c0con current master5d7b538, v0.0.98)tests/nudge.test.ts— "downward reset re-anchors when count drops below the shown reference even if still above baseline (nudge: downward reset compares baseline only, never lastNudgeShownTokens — a high shown-reference is never re-anchored #478)": turn @10000 → inject @55000 (shown=55000) → settle @9000 (abovebaseline−interval=4000, so old code never resets) → assert reset trio + cadence re-fires at @15000. Fails on pre-fix code (10000 !== 9000), passes with the fix.npm run format:checkclean,npm run typecheckclean,npm test1203/1203,npm run buildclean.Notes
format:checkCI gate (8da8374) plus the prettier config/mass-format (1f6c77a,965eb0d). Rebased onto current master cleanly (no conflicts), reformatted the new test block to the repo style, force-pushed. The side issue I initially filed about a "missing prettier config" is obsolete and has been closed as such.Fixes #478