Repository navigation
fix #590: pi plugin mode reports folded usage, suppress host backfill - #591
Conversation
The #408 backfill armed hostCreditTokens in every mode, but billion-context-pi cancels pi's own auto-compaction (wireCompactionDisable) so the uncompressed baseline drives nothing on pi — it only put a >100% footer (302.7%/1M) on the host while the wire actually carried the folded ~57K. Gate the arming at the single chokepoint (armHostUsageCredit): sessions bound to pluginAgent "pi" report the folded request's own usage. omp (anchored- history rewrite accounting) and codex (native-compact interception) keep the #408 uncompressed baseline, as do plain proxy clients.
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-591Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr591.tgz
npm install -g packageThis comment is automatically updated on each push. |
审核完成,结论:approve,可以合并。以下是我的验证记录(全部在 PR head 根因与层次判断#590 的症状是 footer 显示未压缩基线(302.7%/1M)而 wire 上只有折叠后 ~57K。我查证了代码路径:#425/#408 的 backfill arming 内联在三个 Fix 正确性(逐点核对)
测试质量新增的 独立复跑 pre-flight
全量那 1 个失败与本 PR 无关: 顺带发现的小问题(仅报告,不另开 issue):launcher.test.ts:1029 该测试硬编码 E2E 备注本沙箱无可用上游(默认 127.0.0.1:8199 不可达、无 E2E_UPSTREAM_URL),e2e-codex 套件无法在此执行。考虑到改动是纯展示侧门控、且被路径已被新集成测试以 HTTP 级覆盖,风险很低;如按 AGENTS.md 要求合并前跑 e2e,可用 CI 手动触发的 ci-e2e workflow 补一道。 可以合了,merge 留给你。 |
Semantic merge onto current master: master's #554 regex superset kept in util.ts (exceed[_\s]?context[_\s]?size); the raw-body fallback for side-passthrough payload estimates kept, now writing through the confirmed-channel naming; import union with backfillHostUsage (#591). Stale #554 test assertion updated to the confirmed channel (#572).
Semantic merge onto current master: master's #554 regex superset kept in util.ts (exceed[_\s]?context[_\s]?size); the raw-body fallback for side-passthrough payload estimates kept, now writing through the confirmed-channel naming; import union with backfillHostUsage (#591). Stale #554 test assertion updated to the confirmed channel (#572).
What
Fixes #590 — pi plugin 模式下宿主 usage 回填未压缩基线,footer 显示 302.7%/1M 与实际请求(折叠后 ~57K)不符。
Root cause
PR #425 (#408) 的 host usage backfill 在所有模式都 armed
hostCreditTokens,但 billion-context-pi 的wireCompactionDisable取消了 pi 自身的 auto-compact(pi.on("session_before_compact", {cancel:true}),ACP owns compression)——未压缩基线在 pi 上不驱动任何东西,纯粹造成显示混乱。omp(recordAnchoredHistoryRewrite 触发)与 codex(native-compact 拦截)需要真实未压缩口径作为触发器,#408 行为保留。Fix
在唯一的 arming chokepoint 加门:
src/server.ts新增armHostUsageCredit(session, originalMessages, processedMessages, log)——session.metadata.pluginAgent === "pi"时直接 return(credit=0),三个prepare*站点(anthropic/openai/responses)统一走该 helper。所有下游消费者(adapters / loop/core / plugin.ts 的 SSE·JSON patch //acppanel)自动看到 folded 口径,无需逐点修改。Verification
#590: pi plugin mode reports folded usage — host backfill suppressed(tests/host-usage-backfill.test.ts):plugin 头 +/__bili/plugin/toolcompress m00001–m00002 → 断言 fold 发生(upstream body 无 sentinel)且客户端 message_startinput_tokens恒等于上游原始值 100(无回填)。sentinel 放在 turn-1 assistant(首条 user 消息是 kernel 永不折叠的 conversation anchor)。pi(src/agent/pi.ts:59BILLION_CONTEXT_PLUGIN_AGENT === "omp" ? "omp" : "pi",:408 原样 stamp),所以=== "pi"精确命中、零误伤。