Repository navigation
fix: withhold prompt_cache_key stamp when OMP's Cowork transport bypasses fetch interception (#2583) - #2589
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2819-pr.2589.7854bacThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2589.tgz
npm install -g packageInstall instructions are refreshed on each push. |
3fdda00 to
05f6560
Compare
[bot] 🏷 Review 完成(rebased head 上验证)。结构化八问: 1. 是什么问题 2. 什么原因导致的 3. 影响范围与严重程度 4. 怎么修复的 5. 是否有回归问题 6. 是否破坏缓存 7. 是否改了设计方向 8. 是否引入了新的配置 验证记录:PR base(f2b84b6)落后 master 227 个提交→已 rebase 到当前 master(8e7bb12,hunks 逐字一致,rebase 干净);rebased head 上 typecheck clean、定向 lane 测试 116/116(omp-native-identity/plugin-agent/pi-native/omp-native)、fork-adopt 13/13、build green;旧 head CI 11/11 workflows 全绿。rebase + docs 修订已推回 PR 分支(新 head 判定:可合。§7.4 触碰 identity/session-binding 逻辑(打戳闸门)→ 需人合,不能 auto-merge。建议合并前看一眼新 head |
|
冲突 |
05f6560 to
5ccb0fa
Compare
[bot] 🏷 冲突已解,分支已更新到 冲突来源:master 新合入的 #2469(fork-seed 判定, 解法:union——#2469 块在前、本 PR 块在后,两侧代码原样全保留,零内容取舍。已核对合并后区域结构完整(两函数各自闭合)。 rebased head 验证:typecheck clean;定向 lane 测试 138/138(omp-native-identity / plugin-agent / pi-native / omp-native / pi-omp-fork-adopt——最后这个专门覆盖与新 #2469 代码同文件共存的 fork-adoption 路径)。build 与 CI 交给新 head 复跑。 八问对照(相对上一轮 review 的增量):①问题不变;②原因不变;③影响面不变;④修法不变(仅插入位置随 union 调整);⑤回归——新增核查项:#2469/#2585 两块新代码与本 PR 语义无交互(fork adoption 走独立 HTTP origin,#2585 只动 provider 上报),既有行为结论维持上轮逐项结果;⑥缓存不涉及;⑦设计方向不变;⑧新配置不涉及。 判定维持:可合(人合,§7.4 identity-binding 域)。等 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.265-master.5a6d9a7 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #2583
What & why
The native OMP extension's
prompt_cache_keystamping gate (stampPromptCacheKey, src/agent/pi.ts) assumed its native fetch-interception fallback covers every model request whose destination is not already proxied. That assumption broke when OMP introduced the Cowork transport (can1357/oh-my-pi642892ae, proxy handlinge22a5ff2): defaultanthropic/anthropic-messagesrequests are sent over node:https directly — never touchingglobalThis.fetch— unless an explicit proxy (PI_PROXY/PI_PROXY_ANTHROPIC) pushes them back onto Bun's fetch. On those requests the stampedprompt_cache_keyrides verbatim into Anthropic's strict schema → HTTP 400Extra inputs are not permittedon Anthropic subagent delegations (the reported Scout/Haiku failures; the issue's injected-field probe shows Opus is rejected too, so it is transport-shaped, not model-shaped).Fix
A deterministic, evidence-permitlist predicate (
ompCoworkTransportBypassesFetch, exported for tests) mirrors OMP's own egress selection exactly:provider === "anthropic" && api === "anthropic-messages"AND no effectivePI_PROXY/PI_PROXY_ANTHROPIC. When it fires inside the stamping gate's NATIVE branch only, the stamp is withheld and a once-per-process-per-model warning explains that those requests go direct (uncompressed, invisible to the proxy). Missingprovider/apifields cannot conclude bypass → today's optimistic stamp is kept (fail-safe toward #1579 for older hosts). Launcher lanes (/bili/path, MITM whitelist), non-anthropic models and proxy-set hosts are untouched — they reach the proxy at the network layer regardless of transport.Rationale for withholding rather than routing around it: the stamp's sole consumer is bili itself (identity bind + strip-before-forward, #1403/#1579). A mis-stamp is a guaranteed hard 400; a missed stamp degrades identity only (anonymous pfa session; compression still works server-side). #1403 set this trade explicitly.
Behavior changes (old → new)
Config surface
None added. No new config fields, env vars or CLI flags — the predicate reads the host's own existing
PI_PROXY*conventions and the model metadata the host already supplies.Tests
Boundary note (§7.3)
On OMP ≥ Cowork, direct Anthropic traffic is unreachable by bili in any mode — the true fix home is host-side (route Cowork egress through globalThis.fetch / allow custom fetch injection in oh-my-pi). Nothing is submitted cross-repo without owner approval; this PR ships the in-scope part only.