Repository navigation
Conversation
- 不带文本的 reasoning_details 片段在推理块已被正文或工具调用关闭后到达时, 按同一 ID 重新打开推理块,由块的下一次结束带上它,和续上的推理文本一样。 此前只有第一个片段会打开推理块,之后的片段并进累积数组,却没有块结束来带走, 回传时缺失。Gemini 经 OpenRouter 在正文之后才发正文的思考签名,前面有推理 文本时签名就丢了 - 新增测试,用 2026-10-13 从 OpenRouter 录下的分片:Gemini(推理文本与加密的 思考签名)、GPT(摘要与加密推理)、Claude(带签名的思考)各一个调工具的 回合,Gemini 在正文后发签名的回合,以及由录下的分片拼成的、先有推理文本的 同类回合;流式后回传,核对保留与回传的 reasoning_details - 文档:按 index 合并的旧说明改为按线上顺序合并,并说明迟到的片段
ix64
added a commit
to ix64/twilight
that referenced
this pull request
Oct 13, 2026
…e stream" This reverts commit 9821109. Upstream felinics#118 merges reasoning_details in wire order and supersedes the type+index merge here; the late-piece fix is proposed separately in felinics#122. This branch goes back to the errorformat and openai models fixes only.
ix64
added a commit
to ix64/twilight
that referenced
this pull request
Oct 13, 2026
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.
概要
OpenRouter 有时在推理块被正文或工具调用关闭之后,才发来
reasoning_details片段。流式处理原来只在第一次(!reasoningBlockSeen)为不带文本的片段打开推理块。之后到达的片段虽然并进了sp.reasoningDetails,却再没有ReasoningEndPart把它带出去,所以ReasoningPart的元数据里没有它,下一轮回传也缺这一项。reasoning_details的 delta 总会调用startReasoning(chunkID)。块已关闭时,按同一 ID 重新打开它,块下一次结束时带上完整的累积数组。sdk的reasoningAccumulator按 ID 把它并回原来的ReasoningPart,不会多出第二个推理块。推理文本续上时本来就这样重开推理块,这次让只带细节的片段也一样。DeepSeek 的空reasoning_content标记仍不会重开已关闭的块。signature的reasoning.text)在正文之后才发。前面没有推理文本时,由签名打开第一个块,没有问题。前面有推理文本时,块已经被正文关闭,签名就丢了。docs/providers.md里「按index合并」的说明在 fix(completions): preserve streamed reasoning detail order #118 之后已经不对,改成按线上顺序合并,并补上迟到片段的说明。关联
WithReasoningReplay)和 fix(completions): preserve streamed reasoning detail order #118(按线上顺序合并)之后。fix(completions): preserve streamed reasoning detail order #118 已经解决了 Gemini 的reasoning.encrypted与推理文本同在 index 0、被合成一项的问题,本 PR 不改合并规则。验证
reasoning_details_test.go,使用 2026-10-13 从 OpenRouter 录下的流式分片,不透明值只保留前 24 个字符。测试先流式接收,再用WithReasoningReplay(sdk.ReasoningReplay{Field: sdk.ReasoningReplayDetails})回传,核对ReasoningPart上保留的和请求里回传的reasoning_details:reasoning.encrypted(思考签名,id 是工具调用的 id)reasoning.encryptedgo build ./...、go vet ./...、go vet -tags integration ./...、go test ./... -short -count=1 -race、internal/sdkdiff的测试,go mod tidy无变化。golangci-lint:仓库锁定的 2.11.3 在 Go 1.27 下会 panic,所以改用 2.14.0。改动的文件没有报告;其余报告(goconst 等)在 main 上同样存在。行为变化
reasoning_details片段会再触发一对ReasoningStartPart/ReasoningEndPart,ID 与原块相同。按 ID 聚合的调用方(包括sdk自己的ModelResult)得到的仍是一个推理块;只看事件顺序的调用方,会在正文或工具调用之后看到它。