Repository navigation
[PR] fix: re-carry the anthropic cache_creation breakdown on the synthetic terminal - #4074
ranxianglei wants to merge 1 commit into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4911-pr.4074.46abc96This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr4074.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 本 PR 是 #4072(原始缺陷)的修复;open+closed 中无其他覆盖同一失败签名(synthetic terminal 丢失 标签: bug, claude-code, scope/wiring, p2(缓存命中本身正常,丢的是 breakdown 对象与 CCVS 倒计时图标——功能降级有绕行,非缓存泄露类) 进入 review:这是已完成的工作项,不重做——按 PR 审核流程独立重审。初步发现两条,正在处理:
审完给结构化八问结论。 |
… terminal (#4072) The cache_creation breakdown object (ephemeral_5m_input_tokens / ephemeral_1h_input_tokens) lives only in the upstream message_start frame, which #1315 forwards usage-neutral to keep the synthetic terminal the sole usage authority. The breakdown had no other carrier, so hosts deriving their prompt-cache TTL from it (Claude Code VS Code countdown icon) lost it on every turn through bili. Capture usage.cache_creation verbatim per round (start frame unconditional, incomplete message_delta frames only when they carry tokens — same relay zero-echo guard as the numerics) and emit it from buildTerminal next to cache_creation_input_tokens. Stitched turns take the final round's breakdown, matching how the totals are chosen. Never synthesized: absent upstream means absent downstream. The start frame stays neutral, so the #1310/#1315 double-count protection is untouched.
cf8f653 to
fffa539
Compare
(ai: vllm-qwen/qwen3.8-27b) PR Review 结论:#4074(fixes #4072)— 代码与测试通过审查;CI 红已定位为陈旧基线产物,rebase 后新 head 待 CI 确认。 ① 方向审核(原 issue):根因成立。#1315 起 bili 把 anthropic ② 回归审查(diff 触碰路径的既有行为逐项):
③ 代码审查:捕获为逐字透传,不改对象形状; ④ 测试有效性:非 stitched 伴生测试断言 terminal 携带与上游 start frame 相同的对象(回归时抓得住);stitched 测试钉「末轮胜出」;两个负例(上游缺席 → 键缺席;全零 delta 回显不覆盖)。断言有牙。 ⑤ diff 整洁度: CI 红根因(逐 job 日志定位,全部是陈旧基线产物,与本 PR 改动无关):旧 head
已执行:分支 rebase 到当前 master( 结构化八问:
判定:可合并(待新 head CI 绿);合并操作归你:#4074 |
(ai: vllm-qwen/qwen3.8-27b) CI 确认(新 head
注:期间有一条「success」的 CI run 是标签同步触发的 skip-scoped run(plan job 判 scope=skip、测试腿全跳过),不是有效结论——上面这份是真实跑完的矩阵。旧 head 上红的 verif 两条 + #3769 flake 在新基线上不再出现,印证了根因定位(陈旧基线,master 侧 #4084/#4087 已修)。 最终判定不变:可合并。 合并操作归你:#4074 |
What & why
Closes #4072
Since #1315, bili forwards the anthropic
message_startusage-neutral ({input_tokens:0, output_tokens:0}) so the synthetic terminal is the sole usage authority. But Anthropic puts theusage.cache_creationbreakdown object (ephemeral_5m_input_tokens/ephemeral_1h_input_tokens) in exactly that frame, and the terminal re-emitted only the four numeric fields — so the breakdown was lost on every turn through bili. Claude Code VS Code derives its prompt-cache TTL countdown icon solely from that breakdown; it disappeared for every user routed through bili (caching itself kept working).Fix
src/loop/adapter-anthropic.ts: captureusage.cache_creationverbatim per round — unconditional from the start frame, from incompletemessage_deltaframes only when the object carries tokens (same relay zero-echo guard class as the numerics, Redesign #408 host-usage backfill: post-fold by default, baseline opt-in (opencode gap + whack-a-mole exemptions) #660).buildTerminalemits it next tocache_creation_input_tokens.src/loop/core.ts: optionalcacheCreationfield on the loop's usage event / completion opts (pure type plumbing).Behavior change disclosure
Additive wire change on the anthropic lane: the synthetic terminal's
usageobject now carries acache_creationobject (byte-identical to what the upstream start frame had) when the upstream provided one. Old: key absent. New: present when provided. Clients reading the breakdown (Claude Code VS Code countdown) recover; clients ignoring unknown usage keys are unaffected. Totals/cache_read semantics and start-frame neutrality unchanged.Config surface
N/A — no config field added, renamed, or re-semantics'd.
Tests
cache_creationobject as the upstream start frame; the forwarded start stays neutral.cache_creationkey in the terminal; an all-zero schema-shaped breakdown echoed by an incomplete delta does not clobber the start-frame values.