You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kernel-side fix is up: acp-kernel PR#203 (branch 2026-09-06_report-tool-accounting, commit c1634b1).
Fixes here:
tool bucket ~0.6% of real volume — collectVisible classified with toolName ?? "text"; wire adapters only set toolName on tool-calls, so all tool-results fell into text. Now results resolve back to their calling tool via a toolCallId → toolName map; orphans land in a generic tool bucket, never text.
two tool predicates — recommend.tsisToolMessage (contentType-based, correct) is now exported and reused by report.ts.
pct() floor — Math.max(1,…) removed; tiny buckets show 0%, buckets sum ≤100.
Bonus found while testing: merged ranges in the uncompressed view labeled the whole range with the first message's tool (comment claimed dominant) — now tracks per-tool token totals.
panel docstrings no longer claim chars/4; numbers use the core's countTokens (kernel default = CJK-aware defaultCountTokens).
Verification: kernel typecheck ✓, 580/580 tests (5 new in tests/report-tool-accounting.test.ts) ✓, build ✓.
Remaining bili-side work after the kernel release ships (will be a separate PR + acp-kernel pin bump): the 3 buildStatusReport call sites (src/loop/core.ts:148, src/compress-loop-responses.ts:105, src/stream.ts:46) pass estimateTokensFast (chars/4) while the nudge/panel side uses the CJK-aware kernel default — the 4x CJK under-estimate and the mixed scales in one acp_status output.
bili-side fix is up: PR#567 (branch 2026-09-06_acp-status-estimator, closes this issue).
Pairs with acp-kernel PR#203 (v0.0.54, already merged + live on npm):
kernel: tool-results resolve to their calling tool via toolCallId map (fixes the 0.6% tool bucket); pct() floor removed; ranges label the dominant tool.
bili: the 3 buildStatusReport call sites now pass defaultCountTokens (CJK-aware) instead of estimateTokensFast (chars/4) — one estimator scale across the whole acp_status output, matching the nudge/panel side; acp-kernel pinned 0.0.54.
2 new regression tests pin both halves (they fail on 0.0.53 exactly at the old bug signatures 6.1K text (100%) and pass on 0.0.54).
Activity
ranxianglei commentedon Aug 31, 2026
[bot] 🏷 收到,正在排查。先确认根因位置:issue 指出字段选择错误在 acp-kernel(
report.ts:86的message.toolName ?? "text")。我先在本地复现/核对 kernel 源码与 dist 行号,确认修复面(kernel 侧 vs bili 侧),随后给出修复方案与 PR。ranxianglei commentedon Aug 31, 2026
[bot] 🏷 已修复,两个 PR(kernel 侧 + bili 侧):
取证确认(与你的根因分析一致)
report.ts的collectVisible用message.toolName ?? "text";三个 wire 转换器(anthropic/openai/responses)都只在 tool-call 侧设toolName,tool-result 只有toolCallId→ 全部工具结果落进 text 桶。recommend.ts的isToolMessage(contentType,正确)vsreport.ts的 toolName(错误);另外compress.ts的computeContextBreakdown还有第三份内联拷贝。estimateTokensFast(chars/4),nudge 侧走createCore()默认defaultCountTokens(CJK-aware)。Math.max(1, ...)。plugin.ts的unprunedTokens用defaultCountTokens,nudge 的contextBreakdown实际也是defaultCountTokens(createCore()未注入 ports)——算术两侧今天本来就是同尺(都是 CJK-aware),不存在实算混算。真正的缺陷是 kernelpanel.ts的 docstring/注释声称 "chars/4 … both sides are chars/4",文档契约是错的:照文档实现的 host 用 chars/4 算 unpruned 才会混尺(release v0.1.6 #18 家族)。已把注释改成真实契约 + 补同尺回归测试。修复内容
kernel(#177):
src/message-kind.ts导出唯一isToolMessage();report.ts、recommend.ts(删本地拷贝)、compress.ts(删内联拷贝)统一使用 → 消灭定义 fix: address all code review findings (condense, routing, session-id, dead code) #2collectVisible按 contentType 分类;result 侧通过共享toolCallId解析工具名,call/result 两半落进同一个命名桶(Top tools 和 drilldown 的tool:过滤现在对 result 也生效)pct()去掉 1% 地板,小桶印 0%,三桶总和不再 >100panel.ts注释改为真实契约(同createCore的估计器,默认defaultCountTokens)bili(#399):
buildStatusReport调用(loop/core.ts、stream.ts、compress-loop-responses.ts)改传defaultCountTokens→ 整份报告一个刻度,与 nudge/panel 一致server.ts删掉不再使用的estimateTokensFastimport验收对照
buildCompressibleRanges的 toolPct 与 breakdown tool% 一致(修前一个 100% 一个 ~0%)4.0K text (100%)且 chars/4 刻度不出现;kernel 侧 CJK 4000 字符defaultCountTokens→4.0K vsestimateTokensFast→1.0K 对照panel.test.ts新增 CJK 同尺用例(1000 汉字 = 1.0k,chars/4 下会是 250)预检
后续(按 AGENTS.md §5 跨仓规则)
合并顺序:先合 acp-kernel#177 → CI 发布新 acp-kernel → 我验证 npm 上 live 后,再开 bili 的 acp-kernel 依赖 bump PR(exact pin)让 dist 带上 tool 桶修复。两个 PR 的合并都留给人工(系统规则:Agent 不能 merge)。
ranxianglei commentedon Sep 5, 2026
Kernel-side fix is up: acp-kernel PR#203 (branch
2026-09-06_report-tool-accounting, commit c1634b1).Fixes here:
collectVisibleclassified withtoolName ?? "text"; wire adapters only settoolNameon tool-calls, so all tool-results fell into text. Now results resolve back to their calling tool via atoolCallId → toolNamemap; orphans land in a generictoolbucket, never text.recommend.tsisToolMessage(contentType-based, correct) is now exported and reused byreport.ts.Math.max(1,…)removed; tiny buckets show 0%, buckets sum ≤100.defaultCountTokens).Verification: kernel typecheck ✓, 580/580 tests (5 new in
tests/report-tool-accounting.test.ts) ✓, build ✓.Remaining bili-side work after the kernel release ships (will be a separate PR + acp-kernel pin bump): the 3
buildStatusReportcall sites (src/loop/core.ts:148,src/compress-loop-responses.ts:105,src/stream.ts:46) passestimateTokensFast(chars/4) while the nudge/panel side uses the CJK-aware kernel default — the 4x CJK under-estimate and the mixed scales in oneacp_statusoutput.ranxianglei commentedon Sep 5, 2026
[bot] 🏷 先同步一个关键事实:#386 的修复目前不在任何在售版本里——它被 revert 了。
时间线(均为可查证记录):
4d0b61f),两轮 agent review 通过(APPROVE-WITH-NITS,含对抗性 runtime 探针)+ 563 测试全绿;e8081c8Revert,走的是专门分支2026-09-03_revert-ref-reclamation;f14c1c8,v0.0.53)的refs.ts已回到旧代码(无pruneDeadRefs,旧 throw 文案);也就是说:#386 的症状(幽灵 ref 单调膨胀、逼近 99999 throw、orphan-gc 泄漏映射)在 kernel ≥0.0.50 / bili 全部现行版本中仍然存在。
想确认:revert 的原因是什么?commit message 只有一句标准的 "This reverts commit …",PR#176 线程里也没有后续说明。如果是发现了具体问题,请给 repro 或现象描述——我会修根因后重提,而不是盲目把同一个 PR 再推一遍。
我的建议(明确立场,不是甩选择题):该修复本身质量已验证过(两轮 review + 一次真实发布 v0.0.48),分支
2026-08-31_ref-reclamation还在、随时可提。建议原样重新合并,同时补上 review 中唯一的小发现:src/sync.ts:48tokenSnapshot 修剪在"离开视图数 == 进入视图数"时按 count 短路跳过,ref 复用后新消息会继承旧 token 计数(review 方已给出复现和一行修法:改比 key set)。若你对方案本身有顾虑(比如 sync-before-resolve 的行为变化、prefix cache 影响),请指出具体点,我针对性调整。另外澄清一下你这条评论:PR#203(report tool accounting,tool-results 归桶错误)是另一个问题,与 #386 的幽灵 ref 泄漏无关——它独立合并不受影响,但不会解决 #386。(commit message 里写的 "(#386 follow-up)" 如果另有含义请说明。)
ranxianglei commentedon Sep 6, 2026
bili-side fix is up: PR#567 (branch
2026-09-06_acp-status-estimator, closes this issue).Pairs with acp-kernel PR#203 (v0.0.54, already merged + live on npm):
buildStatusReportcall sites now passdefaultCountTokens(CJK-aware) instead ofestimateTokensFast(chars/4) — one estimator scale across the wholeacp_statusoutput, matching the nudge/panel side; acp-kernel pinned 0.0.54.2 new regression tests pin both halves (they fail on 0.0.53 exactly at the old bug signatures
6.1K text (100%)and pass on 0.0.54).ranxianglei commentedon Sep 6, 2026
[bot] 🏷 PR#567 / kernel 0.0.54 本身没问题——tool-result 归桶和 estimator 统一是
acp_status准确性的真实改进,独立合并不受影响。但它不解决 #386,建议不要据此关闭本 issue。查证如下:git log v0.0.53..origin/master只有两件事:c1634b1(PR#203 tool accounting)+ release commit;git show origin/master:src/refs.ts仍是旧代码(无pruneDeadRefs,throw 文案还是cannot allocate beyond m99999)。package.json/lockfile、src/loop/core.ts、src/compress-loop-responses.ts、src/stream.ts、新测试)只涉及 estimator 传参和 pin bump,不碰 refs/sync/boundaries/orphan-gc 任何一条 acp_status 会计缺陷:tool 结果全计为 text + 同一报告两套互斥的 tool 定义 + 双估计器混印不标尺 + pct 地板 #386 的路径。prepareAnthropiccatch 静默停摆压缩、orphan-gc 失活块泄漏映射("active block but none of its content is visible" 仍可达)。这些都在 acp-kernel 侧,bili 侧改 estimator 无法覆盖。另外 floor 7 的问题还悬着:PR#176 被 revert 的原因是什么? revert 走专门分支
2026-09-03_revert-ref-reclamation,v0.0.50 在 revert 后 10 分钟发布,但 commit message 和线程里都没有说明;且 bili 从未 pin 过含修复的 0.0.48/0.0.49(用户侧零暴露),所以 revert 不是被用户回归触发的。修复已按 review 意见补强并本地就绪(acp-kernel 分支
2026-09-05_ref-reclamation-v2:原修复 cherry-pick + tokenSnapshot 按 key set 修剪的回归测试,typecheck / 590 tests / build 全绿)。请给一个明确信号:GO(我立即 push + 提 PR),或revert 的具体原因(我针对性修正后再提)。在此之前我不再重复推送同一变更。Merge pull request #567 from ranxianglei/2026-09-06_acp-status-estimator
fix: acp_status uses one estimator scale — defaultCountTokens (ranxia…
chore: bump acp-kernel to 0.0.56 (fixes acp_status tool-result bucket…