Skip to content

Commit 9d90ac8

Browse files
committed
fix(SDKChatStreamingAdapter): Clarify reasoning accumulation logic to prevent text duplication
1 parent f501137 commit 9d90ac8

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

WebAdmin/src/lib/client/sdkChatStreamingAdapter.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,14 @@ export class SDKChatStreamingAdapter {
124124
}
125125
}
126126

127-
// Also handle reasoning content (for models like gpt-oss-20b that output to reasoning)
128-
const reasoning = data.choices?.[0]?.delta?.reasoning;
129-
if (reasoning) {
130-
totalReasoning += reasoning;
131-
}
127+
// Note: We do NOT accumulate delta.reasoning here because:
128+
// 1. The backend sends reasoning via dedicated "event: reasoning" SSE events
129+
// 2. It also includes delta.reasoning in chunks for compatibility
130+
// 3. Accumulating from both sources causes text duplication
131+
// 4. We only accumulate from the reasoning event (lines 260-272)
132+
//
133+
// If a provider sends ONLY delta.reasoning without reasoning events,
134+
// that's a backend issue that should be fixed by emitting reasoning events.
132135

133136
// Handle tool calls in streaming response
134137
const deltaToolCalls = data.choices?.[0]?.delta?.tool_calls as Array<{

0 commit comments

Comments
 (0)