Skip to content

Commit 62d4e18

Browse files
fix: concatenate reasoning field in streaming response consolidation (#5578)
consolidateTextFields() only concatenated content and function_call from streaming deltas, but not reasoning. This meant reasoning tokens from providers like Gemini with thinking/reasoning would get last-chunk-wins behavior instead of proper concatenation. Adds reasoning field handling alongside content in the delta consolidation logic.
1 parent d7ebdcb commit 62d4e18

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

worker/src/lib/dbLogger/streamParsers/responseParserHelpers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ export function consolidateTextFields(responseBody: any[]): any {
5454
content: c.delta.content
5555
? c.delta.content + (cur.choices[i].delta.content ?? "")
5656
: cur.choices[i].delta.content,
57+
reasoning: c.delta.reasoning
58+
? c.delta.reasoning +
59+
(cur.choices[i].delta.reasoning ?? "")
60+
: cur.choices[i].delta.reasoning,
5761
function_call: c.delta.function_call
5862
? recursivelyConsolidate(
5963
c.delta.function_call,

0 commit comments

Comments
 (0)