Repository navigation
[PR] fix: replay unsigned thinking when the upstream does not sign it (#5495) - #5496
Conversation
An Anthropic-wire upstream that never signs thinking blocks (DeepSeek's /anthropic endpoint) requires the unsigned block passed back on the acp-loop re-request. The signature gate keyed on protocol alone (anthropic|google => require signature), so every such round's reasoning was dropped from the tool_use replay -> 400 invalid_request_error: "The `content[].thinking` in the thinking mode must be passed back." - Gate on per-attempt signing evidence (sawSignedThinkingThisAttempt): require a signature only when THIS attempt actually saw one. Real Claude signs every round, so its behavior is unchanged. - Degraded strip-retry excludes "must be passed back" 400s: stripping perpetuates a thinking-required rejection; propagate the original error instead. Neutral 400s still strip-retry. - strictReasoningEcho learn-on-failure (loop + relay) also matches DeepSeek's Anthropic-wire wording content[].thinking. Behavior change (old->new): on anthropic/google-wire lanes, a round whose attempt shows ZERO signing evidence previously had ALL its thinking blocks dropped from the re-request; they are now replayed verbatim. The #221 pin "unsigned => always dropped" was the buggy generalization and is updated accordingly; a new mixed-block test pins the retained requirement when signing evidence exists.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.7809-pr.5496.31ef6ebThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5496.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 这是 #5495(DeepSeek 已审代码、回归面、测试有效性,并本地独立复跑 + 负控制。按八问作答: 1. 是什么问题 2. 什么原因导致的 3. 影响范围与严重程度
4. 怎么修复的 5. 是否有回归问题
6. 是否破坏缓存 7. 是否改了设计方向 8. 是否引入了新的配置 验证(我做的,非照抄 PR)
判定:可合。 逻辑正确、回归面有界且已披露、测试双向钉死并有负控制实证、CI 无红。建议等 CI 全绿后由 owner 合并(我不合 PR)。 |
|
(ai: vllm-qwen/qwen3.8-27b) Verdict: APPROVE
我独立核过什么(不是复读 issue 结论):
结构化八问:
CI(head e18bbb0):test 全矩阵(ubuntu/windows × node 22/24 × 5 shard)、static-gates、mysql-contract、config-surface-guard 全绿,0 failed / 0 pending(skipped 为 env 门控的 e2e/theorem 车道,默认不跑)。 收工判定:可合(mergeable)。无 kernel 变更、无需决策项、无需在分支上顺手补的小修。合并仍归人(agent 不合 PR)。 |
(ai: vllm-qwen/qwen3.8-27b) 复审完成(review-worker-r1 第二轮)— 结论:APPROVE / 可合,与 floor 4 的初审一致。 我未复读初审结论,独立重走了: GitHub 侧交付说明:完整八问审查已作为评论投递到 PR(comment id 6563355189)。未能提交正式 APPROVE 状态——本环境审核身份即 PR 作者 ranxianglei,GitHub 硬性禁止对本人 PR 自批(422 "Can not approve your own pull request"),此为平台约束、不予绕过,改走评论承载同等实质结论。 CI head |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1006-master.dec393f # this exact build
npm install -g billion-context@master # always the newest merged build
|
…king replay + ranxianglei#5528 additional_tools reachability Eight files; two overlap this lane and both auto-merged: - src/loop/core.ts: master's ranxianglei#5495 replay/exposure hunks sit at :178 and :1317-1331, this lane's draft-dump gate at :1181 and the DEGENERATE_RETRY_NUDGE import at :49. Verified after the merge that both sides are present. - src/server/relay.ts: master's hunk is at :1576, this lane's non-SSE pipePluginJson egress at :1976. Both present. Post-merge: kernel build, tsc, lane suites and the four static gates re-run.
Closes #5495
What was broken
On an Anthropic-wire upstream that never signs thinking blocks (DeepSeek's
/anthropiccompatibility endpoint), every acp-loop re-request (compress or acp_status) died with:The signature gate in
src/loop/core.tskeyed on protocol alone —anthropic|google ⇒ require signature on replayed thinking. DeepSeek's relay emits nosignature_delta, so every round's reasoning was silently dropped from the tool_use replay, leaving the assistant message without its thinking sibling. The degraded strip-retry then compounded it: stripping the loop thinking and retrying guarantees a second 400 on a thinking-required upstream and swaps out the real error.Fix
src/loop/core.ts): require a signature only when THIS attempt actually saw one —sawSignedThinkingThisAttempt, already tracked per-attempt for the [bug] anthropic 线盲重取(#413/#1455)把没签名的 thinking 块交给客户端:下一轮 400 "thinking.signature: Field required",Claude Code 随即永久剥掉全部历史 thinking #2501 refetch bar. Real Claude signs every round → unchanged. An upstream showing zero signing evidence is an unsigned relay → its thinking replays verbatim.src/loop/core.ts): a "must be passed back" 400 now propagates instead of strip-retrying (stripping perpetuates the rejection). Neutral 400s still get the degraded retry — the exclusion is scoped, pinned by a contrast test.src/loop/core.ts+src/server/relay.ts): strictReasoningEcho learn-on-failure also matches DeepSeek's Anthropic-wire spellingcontent[].thinking.Behavior change (old → new)
On anthropic/google-wire lanes, a round whose attempt shows zero signing evidence previously had all of its thinking blocks dropped from the compress/acp-status re-request. They are now replayed verbatim.
signature_deltalost) now replays the block; if upstream rejects it, the existing degraded strip-retry recovers (previously: proactive drop).#221test pin "unsigned ⇒ always dropped" encoded the buggy generalization and is updated with justification; a new mixed-block test pins the RETAINED requirement when signing evidence exists in the attempt (Claude/Gemini fatality rule intact).Tests
New
tests/issue5495-unsigned-thinking-replay.test.ts(5 tests) — each verified to fail against the pre-fix code (negative-control runs for both the gate and the strip-retry exclusion):Targeted suites green locally (209 tests across the loop/reasoning/replay/strict-echo area, incl.
verify-sig-roundtrip,issue539-loop-reasoning,anthropic-truncation-unsigned-thinking); typecheck clean on the rebased head. Full-suite verdict = CI on this head. No config-surface changes, nokernel/changes, no version bump.