fix(proxy): reassemble reasoning_content in aggregated chat completions #19
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/aggregate-reasoning"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
With
aggregate: true, SLP turns a non-streaming chat completion into an upstream stream and reassembles it. The reassembly kept onlydelta.content. A reasoning model streams its chain of thought first, inreasoning_contentdeltas, so:reasoning_content, although the same request sent to the upstream without streaming returns one;max_tokensmid-thought came back as"content": ""with a fullcompletion_tokenscount and nothing to show where the tokens went.usageis carried verbatim, socompletion_tokens_details.reasoning_tokensalready crossed over; only the text was lost.Change
aggregateStreamcollectsdelta.reasoning_contentper choice and emits it as the message'sreasoning_content, besidecontentrather than inside it. The field is omitted when a turn had no reasoning deltas, matching the upstream's own non-streaming response. Reasoning bytes count towardmaxAggregateBytes.Streaming clients and text completions are unaffected.
Verification
TestAggregateChatCompletionReasoningcovers reasoning followed by an answer, reasoning with no answer, and a turn with no reasoning (key absent).go build ./...,go vet ./...andgo test ./...pass.Related: brooktrails/gllm#109 fixes the gllm bug that made constrained answers land in the reasoning field in the first place.
🤖 Generated with Claude Code
Automated review by pr-reviewer v0.52.3 | Safety Check | Granite | tracking id
r-c00a82-f0bbb4This is an AI-generated review and may contain mistakes.
Status: ❌ Failed
Review failed. Tracking id
r-c00a82-f0bbb4— see logs for details.Comment
@pr-reviewer-bot retryto try again.c38635d5a4b9957c8d84