Repository navigation
[PR] fix: drop signature-less thinking blocks for upstreams that reject them (#5998) - #6009
Conversation
…em (#5998) DSH transcripts store reasoning as {type, text} without signatures, so every rebuilt turn carries signature-less thinking blocks that signature-verifying upstreams (Anthropic proper) reject with "thinking.signature: Field required" (#2501). The affected upstream personalities are byte-indistinguishable on the inbound wire - never-signing relays (DeepSeek /anthropic, #5495) require those same unsigned blocks back verbatim - so no static rule can discriminate; learn the personality instead: - src/server/thinking-posture.ts (new): the 400-wording detector, the wire-level strip (signed blocks and redacted_thinking pass byte-exact, KDD#10), and the session-scoped posture. - relay egress seam (src/server/relay.ts): the first "Field required" 400 on an anthropic-lane send triggers ONE strip-and-resend probe (same controlled-experiment discipline as the #2645 pck ladder); accepted => the session remembers strict posture and later sends drop unsigned thinking proactively before egress; still failing => original 400 forwarded verbatim, nothing learned. #5495 "must be passed back" and #1960 "cannot be modified" wordings never enter the probe. - warnAnthropicThinkingPairs: inbound scan narrowed to SIGNED thinking only - an unsigned block is never a replayable asset on any upstream, so its absence from a rebuilt request is by design, not a violation. - WC-024 wire-contract ledger entry + validator clause shared by both anthropic lanes (main + Vertex) + gate test + ledger self-check probe row.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.8763-pr.6009.89cab6dThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6009.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 — GitHub PR #6009 (head 标签: This is a [PR] thread, so I am reviewing, not redoing: pulling head |
(ai: vllm-qwen/qwen3.8-27b) CI fix run for PR #6009 (head now 6f20f3a): the What I verified first (live): mirror cache showed Fix: Live state after the fix (one-off check-run fetch at 06:3x UTC since the mirror cache snapshot was stale): 七问(CI 修复轮)
收工判定:本轮唯一红灯( |
(ai: vllm-qwen/qwen3.8-27b) Review verdict: LGTM — code is merge-quality. I reviewed the FINAL head What I independently verified (not just read from the PR description): Code vs constraints
Regression audit (existing behavior on touched paths)
Local targeted runs at head CI (live-verified): core matrix fully green on One flagged edge (non-blocking): the strict posture is sticky for the session life with no forgetting. If a session later routes to a never-signing relay that wants unsigned blocks verbatim, the learned posture keeps stripping them → standing "must be passed back" 400s until a new session. Candidate follow-up in this thread: unlearn the posture on the opposing wording. Not blocking — it needs a mid-session route switch, and the failure mode is a clean 400, not corruption. Residual seams (count-tokens builder, incremental-lane render, plugin-render legacy rows, WS egress) are already disclosed in the PR body and self-heal via the existing degraded strip-retry. 八问(中文结构化结论)
收工判定:代码质量达标、回归面审过、定向验证全绿,可以合并。合并动作按仓库惯例由你执行:core-scope 下 GitHub 会因 windows-24 必需项未跑而保持 blocked(与 #5966 等近期 PR 的合并路径一致);想要全量矩阵就先加 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1118-master.4be21b0 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Master-side commit 6b0cb61 (#6009) added tests/storage-null-identity.test.ts pinning migrated.to / migrateSchema().from at 11 — master's newest schema at the time it was written. This PR intentionally bumps STORAGE_SCHEMA_VERSION to 12 (src/storage/schema.ts) and already carries updated pins in its own migration tests; the master-added test was written against the pre-bump tree, so its two pins collide after the merge and fail deterministically on every shard. Update both values 11 -> 12; no product-code change.
Master-side commit 6b0cb61 (#6009) added tests/storage-null-identity.test.ts pinning migrated.to / migrateSchema().from at 11 — master's newest schema at the time it was written. This PR intentionally bumps STORAGE_SCHEMA_VERSION to 12 (src/storage/schema.ts) and already carries updated pins in its own migration tests; the master-added test was written against the pre-bump tree, so its two pins collide after the merge and fail deterministically on every shard. Update both values 11 -> 12; no product-code change.
Master-side commit 6b0cb61 (#6009) added tests/storage-null-identity.test.ts pinning migrated.to / migrateSchema().from at 11 — master's newest schema at the time it was written. This PR intentionally bumps STORAGE_SCHEMA_VERSION to 12 (src/storage/schema.ts) and already carries updated pins in its own migration tests; the master-added test was written against the pre-bump tree, so its two pins collide after the merge and fail deterministically on every shard. Update both values 11 -> 12; no product-code change.
Master-side commit 6b0cb61 (#6009) added tests/storage-null-identity.test.ts pinning migrated.to / migrateSchema().from at 11 — master's newest schema at the time it was written. This PR intentionally bumps STORAGE_SCHEMA_VERSION to 12 (src/storage/schema.ts) and already carries updated pins in its own migration tests; the master-added test was written against the pre-bump tree, so its two pins collide after the merge and fail deterministically on every shard. Update both values 11 -> 12; no product-code change.
Closes #5998
Problem
DSH transcripts store reasoning blocks as {type, text} without signatures. Every turn rebuilt from such history carries signature-less thinking blocks, which signature-verifying upstreams (Anthropic proper) reject with "thinking.signature: Field required" (#2501). The mid-session opus→sonnet switch in the report amplifies it: signatures are bound to the producing model.
Mechanism verified in code: kernel
anthropicToCorestampsthinkingSignatureonly when the inbound block carries one, whilecoreToAnthropicre-emits EVERY reasoning core as a thinking block — unsigned cores produce signature-less blocks on the wire.Why not a static rule
The two affected upstream personalities are byte-indistinguishable on the inbound wire: never-signing relays (DeepSeek's /anthropic endpoint, #5495) require exactly those unsigned blocks back VERBATIM ("must be passed back"). A renderer-level drop would break #5495; forwarding everything breaks #5998. So the personality is LEARNED instead of guessed:
src/server/thinking-posture.ts: the 400-wording detector, the wire-level strip (signed blocks and redacted_thinking pass byte-exact, KDD#10), and the session-scoped posture.src/server/relay.ts, same controlled-experiment discipline as the openai wire: prompt_cache_key stamped unconditionally — breaks strict-schema upstreams (NVIDIA NIM 400), no config escape #2645 pck ladder): the first "Field required" 400 on an anthropic-lane send triggers ONE strip-and-resend probe. Accepted ⇒ the session remembers strict posture and every later send drops unsigned thinking proactively before egress (the client sees one transparent self-heal; later turns pay nothing). Still failing ⇒ the original 400 is forwarded verbatim and nothing is learned (the next turn re-runs the experiment).warnAnthropicThinkingPairs: inbound scan narrowed to SIGNED thinking only — an unsigned block is never a replayable asset on any upstream, so its absence from a rebuilt request is by design, not a violation.Behavior change disclosure (old → new)
session.metadata.thinkingSignatureStrict, persisted with the session record); NO new config surface.Residual seams (noted, deliberately not fixed here)
The probe seam covers the main relay path (
forwardCaptured). Egress paths that do NOT pass through it: the count-tokens request builder (src/server.ts), incremental-lane render (src/incremental-lane.ts), plugin-render legacy stored rows (src/plugin-render.ts), WS lane egress. The acp-loop re-request path already self-heals today via its existing degraded strip-retry (src/loop/core.ts) — "Field required" matches none of its exclusion clauses, so it strips and retries per occurrence without this change.Tests
tests/issue5998-unsigned-thinking-egress.test.ts(new): detector unit rows (positive wordings incl. the pinned [bug] anthropic 线盲重取(#413/#1455)把没签名的 thinking 块交给客户端:下一轮 400 "thinking.signature: Field required",Claude Code 随即永久剥掉全部历史 thinking #2501 string; negatives: Anthropic-wire upstream without thinking signatures (DeepSeek /anthropic): compress re-request drops reasoning from the tool_use replay → 400 "content[].thinking must be passed back" #5495 mandatory wording, [acp-loop] In-turn compress re-request edits the latest assistant message → Anthropic 400 "thinking blocks … cannot be modified" (session stays broken) #1960 tamper wording, unrelated 400s, non-400 statuses), strip unit rows (signed/redacted/text survival byte-exact, pure-unsigned-thinking turn dropped with role-alternation repair, no-op on clean/non-JSON bodies), posture rows, and full-proxy e2e against scripted upstream personalities: strict self-heals in one turn + later turns drop proactively (exactly one upstream hit each); lenient keeps receiving verbatim, nothing learned; persistent signature-wording 400 forwards verbatim, learns nothing, re-probes next turn; mandatory-thinking 400 NEVER probes; tamper 400 NEVER probes.tests/reasoning-echo.test.ts: fixtures now carry signatures where the test's point is pair-loss, plus three new sentinel rows (both directions per Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617).tests/wire-contract.test.ts+tests/wire-contract-fakes.ts: WC-024 gate (legal signed deepEqual [] / illegal unsigned / empty-string signature) + ledger self-check probe row.