Repository navigation
fix(messages): always include signature on thinking blocks - #278
Merged
Merged
Conversation
7d72818 dropped the `signature` key from thinking blocks when upstream had no real signature, on the assumption that Grok Build rejects `signature: ""`. The opposite is true: Grok Build deserializes `ContentBlock::Thinking` with a required `signature: String`, so an empty string parses fine while a missing key fails the whole response / SSE event with "missing field `signature`". The streamed content_block_start never carried the key at all. Match Anthropic's wire shape instead: - non-stream: thinking block always has `signature` (real value or "") - stream: thinking content_block_start carries `signature: ""`; signature_delta is still only emitted for a real upstream signature Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
已部署到生产实例验证(
修复前的失败依据:同一实例返回的 thinking 块缺少 |
Owner
|
谢谢 —— 这个修得对,已经合了( 我把两边的说法都查了一遍:原来那句「strict clients 会把 我另外核了三件事:
一句实话:这个 PR 的 CI 这次没有跑(当时 GitHub Actions 故障、托管跑者的分配在延迟)。我的证据是我这边按你的 head 另外你开的 #277 我先留着,里面那条「signature 必填」的来源写得很清楚,后来的人会用到。 |
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.
改了什么 / What changed
/v1/messages的 thinking 块现在始终带signature字段:{"type":"thinking","thinking":"..."},现在{"type":"thinking","thinking":"...","signature":""}(上游有真实签名时为真实值)content_block_start之前是{"type":"thinking","thinking":""},现在是{"type":"thinking","thinking":"","signature":""}。signature_delta行为不变,仍只在上游给出真实reasoning_signature时发送。为什么 / Why
Fixes #277
Grok Build 把
ContentBlock::Thinking.signature反序列化为必填的String,缺字段时整条响应 / SSE 事件都会失败(missing field signature);空字符串可以正常解析。7d72818 依据"Grok 拒绝signature: \"\""删掉了这个字段,但实际情况正好相反。本 PR 恢复 Anthropic 的线上格式。已验证:
xai-grok-sampling-types/src/messages.rs、xai-grok-sampler/src/client.rs),确认它对每个 SSE 事件做严格 serde 解析""可以正常解析测试 / Testing
restart.test.js中失败的 2 条(detectSupervisor: "reports unsupervised when nothing matches"、"override value other than "1" is not honoured")在未打补丁的origin/master上同样失败,原因是本机环境被识别为 supervisor,与本改动无关。Checklist
🤖 Generated with Claude Code