File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -342,23 +342,26 @@ func (cs *openAIChatSession) SendStreaming(ctx context.Context, contents ...any)
342342 }
343343
344344 // Handle tool call completion
345+ var toolCallsForThisChunk []openai.ChatCompletionMessageToolCall
345346 if tool , ok := acc .JustFinishedToolCall (); ok {
346347 klog .V (2 ).Infof ("Tool call finished: %s %s" , tool .Name , tool .Arguments )
347- currentToolCalls = append ( currentToolCalls , openai.ChatCompletionMessageToolCall {
348+ newToolCall := openai.ChatCompletionMessageToolCall {
348349 ID : tool .ID ,
349350 Function : openai.ChatCompletionMessageToolCallFunction {
350351 Name : tool .Name ,
351352 Arguments : tool .Arguments ,
352353 },
353- })
354+ }
355+ currentToolCalls = append (currentToolCalls , newToolCall )
356+ // Only include the newly finished tool call in this chunk
357+ toolCallsForThisChunk = []openai.ChatCompletionMessageToolCall {newToolCall }
354358 }
355359
356- // Create a streaming response with proper nil checks
357360 streamResponse := & openAIChatStreamResponse {
358361 streamChunk : chunk ,
359362 accumulator : acc ,
360363 content : "" , // Default to empty content
361- toolCalls : currentToolCalls ,
364+ toolCalls : toolCallsForThisChunk ,
362365 }
363366
364367 // Only process content if there are choices and a delta
You can’t perform that action at this time.
0 commit comments