Repository navigation
feat: compat.dropFields — per-provider deletion of client-fixed fields (SenseNova strict-schema 400) - #1858
Conversation
[bot] 🏷 PR #1858 审查完成。结论先行:代码质量 PASS,但现状不可合并——分支落后 live master 237 个提交,与当前 master 存在 3 处文本冲突 + 1 处语义碰撞(wire-rule 编号撞号),需 rebase 后才能合并。细节如下。 结构化七问1. 是什么问题:SenseNova 的 Responses 网关(token.sensenova.cn/v1/responses)做严格 schema 校验,对 pi-ai 固定发送的 2. 什么原因导致的:客户端 wire 形态与严格上游不匹配——pi-ai 发送的 3. 怎么修复的:新增
4. 是否有回归问题:默认行为不变,由测试钉死(e2e C「未配置 ⇒ 字段原样到达上游」+ WC 负控「未配置 ⇒ byte-for-byte 转发、上游 400 原样 relay」)。但热文件竞争导致必须 rebase,这是本次审查的核心发现:
5. 是否破坏缓存:否。prompt-cache stamp 在删除之后执行,digest 基于删后字节计算——同一 provider 配置下确定性输出;未配置会话字节级不变(prefix cache 不受影响);缓存/重试/增量游标/去重键策略均未触碰。 6. 是否改了设计方向:否。沿用现有 7. 是否引入了新的配置:是—— Wire-contract ledger(#1304 纪律)合规:WC 条目含 provenance(#1757 逐字段实测日期/网关)、fake 强制器注册( CI 状态
判定代码:PASS。可合并性:blocked,需 rebase。rebase 要求:① 三个 union 解法(见上);② WC-011 → WC-013 全量改名;③ push 后等新 CI(diff 触及 src/server.ts,e2e 会自动触发)。 按协议我未动分支。owner 回复「继续」我就执行 rebase(union 解法 + WC-013 改名)并推送,然后回报 CI 结果。 |
|
解决冲突后重新审核 |
[bot] 🏷 收到。开始执行:rebase 到 live master( |
…s for strict-schema upstreams (#1757) Opt-in dot-path field deletion on the final forwarded body: global and per-provider lists merge additively, structural key deletion only (string values untouched), byte-for-byte when nothing matches. Applied after roles/steering before the prompt-cache stamp, wired into wireTransform for compress retries, and chained after scrubAnthropicPck on all verbatim passthrough branches. WC-011 added to the wire-contract ledger with negative/positive gate tests. CONFIGURATION.md en/zh document the key with the canonical SenseNova example.
771e7ea to
aedd29c
Compare
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1856-pr.1858.da94d23This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1858.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 已按指示完成 rebase(解决冲突)并重新审核。结论:代码 PASS,可合并 —— 仅剩主 CI 的全量测试矩阵还在跑(详见下方 CI 节),收尾后补一条确认。 Rebase 与冲突处置
本地定向验证(全量回归交给 CI)
CI(新 head
|
Every server constructed without a compat block (all hand-built test opts, any embedder passing minimal options) crashed per request with 'TypeError: Cannot read properties of undefined (reading dropFields)' at server.ts:1495/:5528, hanging the full test matrix in CI for 40+ min. Matches the existing optional-chaining style of the roles call site (:5491 opts.compat?.roles). resolveCompatDropFields already tolerates undefined.
|
修了 test-matrix 挂起:两处 |
[bot] 🏷 已独立验证 对修复的独立核验
根因分层确认(与你的诊断一致)
诚实复盘(我的 review 缺口)这个缺陷是我前两轮 review 漏掉的:我的定向 e2e 走真实 config 文件 → 七问(终态)
判定可合并,等人按按钮。代码两轮 review PASS + 冲突并集解决 + 可选链修复 + 9/9 CI 绿(独立核验)。无需另立 issue(修复在 #1757/#1858 范围内,已落 PR 分支)。 |
What
Adds
compat.dropFields: string[](global + per-provider) — opt-in deletion of client-sent fields from the final forwarded body, for strict-schema upstreams that reject a field the client always sends but the upstream does not accept (#1757).Repro anchor: SenseNova's OpenAI-Responses-compatible gateway (
https://token.sensenova.cn/v1/responses) returns400 json: unknown field "summary"on pi-ai's fixedreasoning: { effort, summary: "auto" }; every other pi-ai outbound field measured 200 in the issue's per-field curl matrix.Design (owner-decided shape A, sign-off in issue)
reasoning.summary); no wildcards, no array indices; malformed entries dropped at parse time.compat.roles' per-key override.Application points — drops sit at the outbound forward boundary, so both compression modes are covered:
forward()): after compat.roles / output steering, before the [design] chain checkpoint step 3: carrier stamp shape on role-alternation-strict wires (anthropic/google) #1421 prompt-cache stamp; wired intowireTransformso compress-retry re-sends carry the same drops.scrubCompatDropchained afterscrubAnthropicPck([Bug] bili omp 扩展 stampPromptCacheKey 无条件注入顶层 prompt_cache_key —— 严格 schema 上游(opencode zen anthropic 端点)全量 400 #1403) at all five existing sites (passthrough mark 「BUG」native-intercept 进程级 globalThis.fetch 补丁按 URL 形状接管所有模型流量,无关调用者(如 MemOS)被卷入宿主压缩流程 #1117, bypass header opencode v1: keep opencode-acp legacy sessions working after switching to bili #920, non-conversation relay [Bug] DSH native fetch 拦截误伤非 LLM 端点:任何以 /messages 结尾的 URL 都被当成模型 API #1284, side passthrough 标题生成等侧请求污染主会话状态:prepareAnthropic 缺 isTitleGen 守卫、快照无条件覆盖、survivedCount 每请求空转 #388, decode-fail/unrecognized fallback) — the route [Bug] bili omp 扩展 stampPromptCacheKey 无条件注入顶层 prompt_cache_key —— 严格 schema 上游(opencode zen anthropic 端点)全量 400 #1403 already fixed, walked as-is per owner direction.New module
src/compat-drop.ts(parse/resolve/drop helpers); config plumbing insrc/config.tsmirrorscompat.roles(FileConfig → resolved ProxyOptions + ProviderRoute).Config surface (AGENTS.md discipline)
compat.dropFields?: string[]— in the globalcompatblock AND per-providerproviders.<url>.compat.compat.rolesremaps role values (bounded value domain, openai/responses wires only);passthroughdisables bili entirely for a route; the [Bug] bili omp 扩展 stampPromptCacheKey 无条件注入顶层 prompt_cache_key —— 严格 schema 上游(opencode zen anthropic 端点)全量 400 #1403prompt_cache_keystrip is hardcoded to bili's own stamped field. Client-quirk field deletion needs a data-driven path list.compatblock — same species asroles("client sends X, upstream rejects X"), same application point, no new top-level section (the feat: opt-in for non-http(s) baseUrl providers to ride bili (#1392) #1437→One-shot: named providers as real lanes — bind + compactionOptIn + agent-side switch, landing in a single PR (replaces #1466 staging) #1469 cautionary case).Behavior change flag
None. Inert unless configured; the unconfigured path preserves original string identity (no re-stringify), protecting the #661 byte-fingerprint contract. No thresholds/timing/output-format drift anywhere else in the diff.
Wire-contract ledger (#1304)
WC-011 added to
WIRE_RULES(provenance: #1757, 2026-09-30 per-field measurement): responses wire must not carryreasoning.summary; the validation-parity fake enforces it with its native 400 envelope. Gate tests pin both sides: unconfigured bili forwards untouched (fake 400s, WC-011 violation recorded, field byte-for-byte on the wire) and configured bili strips before forward (200, zero violations, siblingreasoning.effortsurvives).Docs
CONFIGURATION.md + CONFIGURATION.zh-CN.md: global and per-provider
compatsections documentdropFields(semantics, merge rule, string-leaf safety, canonical SenseNova example from the issue).Pre-flight
npm run typecheck— cleantests/compat-drop.test.ts— 11/11 (units for all four exports + e2e A–E through a real proxy instance: processed responses path, verbatim fallback, default transparency, additive merge, string-leaf fidelity)tests/wire-contract.test.ts— 13/13 incl. new WC-011 negative/positive gates + ledger self-checknpm run build— clean (acp-kernel inlined)src/server.ts, so the e2e workflow auto-triggers.Fixes #1757