Repository navigation
[PR] batch-3: 6 P1 fixes from the community's open PRs (verbatim cherry-picks, authorship preserved) - #7107
Conversation
(cherry picked from commit 414002a)
…ompresses Claude Code uses Message Threads through the proxy: each continue carries only the new messages, so bili can neither nudge nor fold it (#2701). For a Claude Code session bili compresses, bili now answers a threads request with the 400 Anthropic gives for an unknown beta header. Claude Code drops the header and threading for the session and retries with the full history, which bili folds as usual. A session counts as one bili compresses when its bili MCP tools are on the wire, or, since Claude Code defers MCP tools behind tool search, when bili's MCP server registered its x-claude-code-session-id. Only Claude Code is declined: another Anthropic-wire client may not drop threads on the 400. Requests without bili's tools keep the threads lane. Fixes #6915 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 96274c7)
…/clear Claude Code /clear (or /new) starts a NEW session id but keeps the stdio MCP child running, so the spawn-time CLAUDE_CODE_SESSION_ID env (mcp.ts's CONVERSATION_FROM_ENV) goes stale and neither recovery path fires: the #656 404 adoption needs the bound id to be unknown (it is still registered + active, so calls succeed against it) and the #4168 409 re-bind needs a witness conflict (none occurs). Tools silently run against the OLD session and the NEW session never enters plugin mode. The claude entry now injects a resolver that reads the host's CURRENT session id from <CLAUDE_CONFIG_DIR|~/.claude>/sessions/<host-pid>.json (rewritten on /clear; the host pid is stable for this child's lifetime). On each tools/call the shim re-reads it and, when it differs from the bound id, re-binds + re-registers so the new session enters plugin mode. Identity-bound hosts only; dist/mcp.js (codex/zcode/kimi) is untouched — the resolver is injected solely by the claude entry. Closes #6361 (cherry picked from commit 029b7e0)
(cherry picked from commit 9378f68)
A Remote Control child (claude --print --sdk-url … --resume=<session url>) spawns the shim under a fresh CLAUDE_CODE_SESSION_ID, then sends its model requests under the remote session's id. The shim registered the spawn id, so the proxy never saw the session as one bili compresses. The #6361 re-bind ran only on a bili tool call, and found the host only by a process named claude. The claude entry now re-checks the host's sessions file on a 1 s timer from start-up (watchClaudeSession), and isClaudeHostArgv accepts a native install path <data dir>/claude/versions/<x.y.z>, which is how Remote Control spawns its children. Fixes #6917 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit b521f47)
…6861) Claude Code stamps a cache_control breakpoint on its last message and moves it as the conversation grows. anthropicToCore harvests those marks into a per-request map that coreToAnthropic re-emits verbatim, so the message that carried the breakpoint last turn loses it and its bytes rewrite mid-history on every request, collapsing the prefix cache. Pin client-managed breakpoints cumulatively, the same discipline as bili's own marks: a marked message stays marked until it folds away, within the 4-breakpoint budget. Proxy mode only; in plugin mode the host owns the rolling marks. (cherry picked from commit 753d7a3)
…otiation The session_start and model_select handlers are fire-and-forget, so a throwing pi.setModel propagated as an unhandled promise rejection that could crash the host process. Catch and log it, matching the OMP repin convention; the before_agent_start call site keeps its own guard as defense in depth. Update the reject-case test to assert the error is handled instead of propagated. (cherry picked from commit 5cac542)
(cherry picked from commit 85fd890)
…e from the side lane The preflight egress-fuse probe block keys on !prepared.sidePassthrough, but side requests never reach preflight — handle.ts forwards them with a minimal prepared before the preflight call, and bodies over the effective window are already rejected locally by the side payload guard (#554, 413 side_request_payload_too_large). Pin that exact shape (stuck estimate meter + body above the fuse's 1M floor) so a future change that routes side traffic through preflight, or makes the new block apply to side, fails here. Lane-suite discipline per #2170: the lane-symbol line in src/server.ts (#7009) lands with the dedicated side-lane suite. (cherry picked from commit 27d0349)
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10700-pr.7107.847bfd4This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr7107.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 查重: 不重复。这是 owner 开的批量收编 PR(batch-3),把 6 个社区 P1 修复原样 cherry-pick 进来。我核对了 open/closed 的 [PR] 列表:源 PR(#7097/#6918/#6920/#6869/#6797/#7009)与 #6478 都是被本 PR 收编的对象,不是并行重复;另一个 batch(wave-11 #6830)明确排除了 #6797/#6818,与本批次文件/修复无重叠。 审核方式: 拉取 PR 分支逐 commit 读源码 + 对照 master 验证既有行为 + 核对 cherry-pick 逐字性 + 查 CI 状态。 核对结果:
八问(批量整体):
合并判定: 代码层面可合——六个修复各自正确、门控清晰、回归测试有牙、无无意回归、无 kernel/config 变更。但有两点须 owner 把关: ①CI 仍在跑,合并须等 test 各 shard 绿;②这是 6 合 1 的批量 PR(触碰 src/server.ts 热文件 + 两处 wire 行为变更),按 §7.4 不属于 auto-merge 范畴,且批量收编后 6 个源 PR + #6478 要按 superseded 关闭——合并动作与后续关单请 owner 执行。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1230-master.4b77eab # this exact build
npm install -g billion-context@master # always the newest merged build
|
batch-3: 6 P1 fixes from the community's open PRs (verbatim cherry-picks, authorship preserved)
本 PR 把 6 个社区提交的 P1 修复原样收进来(逐 commit cherry-pick
-x,作者、commit message、测试全部保留)。每个修复独立评审过(对照 master 读全部源码 + 分支上跑测试 + master 上验证新测试确实红),文件互不重叠,零冲突。每个 PR 是干嘛的
1. #7097 → #7096 [codex] compaction 门控只看实测证据
statusInputBaseline,该函数在没有实测 usage 时会替换成本地估计值。估计值可能把门控推错方向:估计偏高 → 错误放行上游自己跑 foreign compaction;估计偏低 → 错误由 bili 伪造。evidenceInputBaseline(src/session.ts:961),只接受usage/overflow-arm来源的实测值;statusInputBaseline其余调用方(status/ACP 读数)行为不变。2. #6918 → #6915 [claude-code] 拒收 message-threads beta
message-threads-*beta 时发 thread delta 请求,走 threads lane 无法压缩。3. #6920 → #6915 [claude-code] MCP shim 跟随 RC 子会话重绑
/clear(新 session id,同 stdio 子进程)或 Remote Control 收养后,shim 仍持有旧 session id 注册和转发,且现有两条恢复路径(MCP tools fail with 'unknown plugin conversation' after Claude Code --resume (shim holds a stale session id) #656 404 收养 / [Bug] Claude Code native compaction: compress/acp_status permanently broken after resumption — outbound tool witness doe | [Bug] Claude Code 原生 compaction 续接后 compress/acp_status 永久失效:outbound tool witness does not match conversationId,ref 空间为空 #4168 409 重绑)都不触发。<CLAUDE_CONFIG_DIR>/sessions/<host-pid>.json,id 变化时重绑 + 重新注册;1s 轮询 + 每次 tools/call 双触发。IDENTITY_BINDING门控保证 codex/zcode/kimi 下零作用。文件读全程防御性(半写文件 → 下轮重试,永不崩)。029b7e09d+9378f6875)不在 master,第三个 commit 引用它们的符号——必须整体收(本批次已整体收),[PR] fix: re-bind the claude MCP shim to the host's current session after /clear #6478 不可单独再合并。4. #6869 → #6861 [claude] 固定客户端缓存标记,中途历史字节稳定
cache_control挪到最后一条消息上,bili 只重发当前请求的标记集合 → 上一轮被标记的消息丢失cache_control字节 → 每轮请求都在改写中途历史 → 前缀缓存塌到只剩 system(实测单请求命中 8.7%)。pinClientMessageMarks(src/loop/cache-control.ts,+95 行):见到客户端标记就固定重发,消息被折叠才退休(liveIds过滤,session metadata 存储,无跨会话/跨 lane 泄漏路径);预算 = 4 − system 标记 − tools 标记,溢出只淘汰最旧的 pinned(永不动当前标记)。plugin mode(宿主自管标记)刻意不动。5. #6797 → #6796 [pi] 协商完整 Anthropic 请求
session_start/model_select(+before_agent_start兜底重试)用官方setModel设 session 级compat.supportsMessageThreads=false。双门:确有 bili 路由声明(proxyBaseForCtx,kill-switch 关闭则不触发)且流量确实被改写(MITM 白名单/proxy origin/拦截器)。模型对象克隆后修改,共享 catalog 不被污染;setModel 拒绝/抛错 → warn + 原样。pi-native环境噪音)。6. #7009 → #6459 [opencode] preflight 折叠会被本地 egress 熔断挡的探针
max(declared, MIN_ASSUMED_WINDOW_TOKENS)、同 method/sidePassthrough 门、同严格>)。命中即走正常压缩折叠。著作权
-x,无改写。作者:ReineLan([PR] fix: use measured evidence for Codex compaction gating #7097)、MohammadErfan-Jabbari([PR] fix: decline the message-threads beta for Claude Code sessions bili compresses #6918、[PR] fix: claude MCP shim follows a Remote Control child's session id #6920)、sx4im([PR] fix: pin client-managed cache marks so mid-history stays byte-stable (#6861) #6869)、shreynshah([PR] fix(pi): negotiate full Anthropic requests for bili #6797)、WHUrubbish([PR] fix(preflight): fold probes blocked by the local egress fuse #7009)。commit message、测试文件、-xtrailer 全部保留。本 PR 合并后
以下 PR 可以按 superseded 关闭(内容已整体进来):
验证
npm run typecheck✅ /npm run build✅(Node v25.9.0)Fixes #7096, Fixes #6915, Fixes #6861, Fixes #6796, Fixes #6459