fix(messages): omit empty thinking signature instead of signature: "" (strict clients reject it)#228
Merged
Merged
Conversation
…ature: "" Our upstream never emits an Anthropic thinking signature, so the proxy sent signature: "" (and an empty signature_delta). Strict clients (e.g. Grok Build's messages backend) reject an empty-string signature as invalid. Omit the field when there's no real signature; forward it verbatim when upstream provides one. - src/handlers/messages.js: non-stream openAIToAnthropic omits signature unless reasoning_signature is present; AnthropicStreamTranslator only emits signature_delta when a real delta.reasoning_signature arrived - test/messages.test.js: assert the field/delta is absent without a real signature; real-signature round-trip preserved
Owner
|
已合并,谢谢 🙏 这条改得对,而且原来的注释其实自己就埋了线索 —— 它写着空串是 "Foxfishc-verified safe fallback",但那个验证只覆盖了当时那个客户端。 流式那半修得尤其对:原来是无条件发 上游将来真给 signature 仍原样透传,前向兼容没丢。 已加入致谢名单,评级 B+。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
中文 TL;DR
上游从不产出 Anthropic thinking signature,代理原来发 signature:"",严格客户端
(如 Grok Build 的 messages 后端)会判为非法。改为无真实签名时省略该字段;上游给了
真实签名则原样转发。
Summary
signature: ""on an Anthropic thinking block is a proxy-synthesized placeholder,not a real Anthropic signature (our upstream never emits one). Some strict clients
reject the empty string as invalid. Omit the field when there's no real signature;
forward a real one verbatim when upstream provides it (forward-compat).
Fix
src/handlers/messages.js:openAIToAnthropic: build the thinking block withoutsignatureunless
reasoning_signatureis present.AnthropicStreamTranslator: emitsignature_deltaonly when a realdelta.reasoning_signaturearrived (drop the empty-string fallback).Test plan
test/messages.test.js: signature/delta absent without a real signature(non-stream + streamed); real-signature round-trip preserved
test/anthropic-input-validation.test.js: no regressionsnpm test→ 2761 pass / 0 failBranch is on current
master(v3.5.0), applies cleanly.