Repository navigation
Description
Version: 0.1.212 (also on current master 23a826d), inline lane with pi, Anthropic messages wire.
With cacheKeepalive.enabled: true the keepalive never arms for my sessions, no [keepalive] armed line at all.
From what I see the client sends breakpoints as "cache_control": {"type": "ephemeral"} with no ttl (which is 5m by default on the Anthropic API). detectKeepaliveTier only set a tier when ttl is explicitly "1h" or "5m", so it return undefined and armInternal exit silently:
billion-context/src/cache-keepalive.ts
Lines 119 to 140 in 23a826d
| export function detectKeepaliveTier(body: unknown): "5m" | "1h" | undefined { | |
| let found: "5m" | "1h" | undefined; | |
| const walk = (n: unknown): void => { | |
| if (found === "1h" || n === null || typeof n !== "object") return; | |
| if (Array.isArray(n)) { | |
| for (const item of n) walk(item); | |
| return; | |
| } | |
| const o = n as Record<string, unknown>; | |
| const cc = o["cache_control"]; | |
| if (cc && typeof cc === "object" && !Array.isArray(cc)) { | |
| const ttl = (cc as Record<string, unknown>)["ttl"]; | |
| if (ttl === "1h") { | |
| found = "1h"; | |
| return; | |
| } | |
| if (ttl === "5m") found = "5m"; | |
| } | |
| for (const v of Object.values(o)) walk(v); | |
| }; | |
| walk(body); | |
| return found; |
if (ttl === "1h") {
found = "1h";
return;
}
if (ttl === "5m") found = "5m";The docs say otherwise (tier is 1h when any breakpoint declares ttl: "1h", else 5m):
billion-context/CONFIGURATION.md
Line 705 in 23a826d
| - **Cadence.** `tier × ttlFactor`, where tier is `1h` when any breakpoint declares `ttl: "1h"`, else `5m`; default factor `0.9` → roughly one ping per 4.5 min / 54 min. Override with `assumeTtl` (skip body detection — for relays that inject or rewrite `cache_control` TTL downstream of bili) or absolute `intervalMs` (wins over everything); `armWithoutBreakpoints: true` arms even breakpoint-less bodies (pairs with `assumeTtl`). |
Repro:
"cacheKeepalive": { "enabled": true }inbillion-context.json- Send any request where the
cache_controlblocks have nottl - Nothing arms, the session row has no keepalive state
Setting assumeTtl: "5m" works around it (armed tier=5m(assumed) cadence=270s), but then I hit #5666.
I guess the fix is to treat a cache_control object without ttl as 5m.
Activity
ranxianglei commentedon Nov 4, 2026
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)
查重: 不重复。keepalive 特性本体是 #3376/#3390(已合并关闭);本条是它的一个独立缺陷——无
ttl的断点从不武装。与你用assumeTtl绕过后撞到的 #5666 是另一机制(保活定时器让短命进程活到 maxDurationMs),不在本条范围。标签: bug · pi · scope/wiring · p2(缺陷;pi 车道 Anthropic wire;保活属请求管线/接线面;有
assumeTtl绕行故 p2)PR: #5669 (Closes #5665)
八问
cacheKeepalive.enabled: true,但断点写成 Anthropic 默认形式cache_control: { type: "ephemeral" }(不带ttl)时,保活从不武装,日志里没有任何[keepalive] armed。detectKeepaliveTier(src/cache-keepalive.ts)只在断点显式带ttl: "1h"或"5m"时才定档;不带ttl时返回undefined,armInternal走到最后那个return静默退出。而 Anthropic 上 ephemeral 断点缺省就是 5 分钟 TTL——这种断点本就该算 5m 档,检测漏掉了它。CONFIGURATION.md 写的正是「任一断点声明ttl: "1h"则 1h,否则 5m」——文档是对的,代码错了。ttl的会话(这是最常见的写法)——保活完全失效,空闲期后下次请求付全价冷重建。有绕行(assumeTtl: "5m"),但会撞到 [Bug] cache keepalive timer keeps short lived processes (pi -p, sub-agents) alive until maxDurationMs #5666。属「个别功能异常 + 需绕行」= p2。ttl的cache_control断点」一律按 5m 档处理,只有显式ttl: "1h"才升档。detectKeepaliveTier里一行逻辑改动(if (ttl === "5m") found = "5m"→ 无条件found = "5m")。undefined(仍靠assumeTtl/armWithoutBreakpoints武装);intervalMs优先级不变;ping 体构造buildPingBody未动。新增回归测试在旧代码上红(两条断言not ok)、修复后绿(文件内 35/35 通过);typecheck + build 干净,全量以远程 CI 为准。/acp-cache命中账本),本次只改「该不该武装、按哪档节拍」。行为变更披露(旧 → 新):断点省略
ttl的会话,过去从不武装 keepalive(静默无操作);现在按 5m 节拍武装(tier × 0.9 ≈ 270s)。零cache_control断点的 body 行为不变。无需改 CONFIGURATION.md(文档本就正确)。判定:可合。纯单模块
fix:、带回归钉、diff 干净、不动内核 / wire 形状 / 配置面 / 版本号。合并留给你。fix(cache-keepalive): treat ttl-less cache_control breakpoints as 5m …
docs: correct no-ttl breakpoint issue reference (#5667 → #5665)