From 2b23bcb91ab96b4e954e3f2edfd39c3222290e80 Mon Sep 17 00:00:00 2001 From: rabi Date: Wed, 31 Dec 2025 22:04:03 +0530 Subject: [PATCH] fix(openai): handle interleaved streaming chunks in tool call argument accumulation Some OpenAI-compatible APIs send interleaved chunks with content:null between tool_calls chunks during streaming. This caused premature termination of argument accumulation, resulting in empty tool call arguments. Changes: - Remove early done=true when chunk has no tool_calls - Accept any finish_reason (not just 'tool_calls') to mark completion Signed-off-by: rabi --- crates/goose/src/providers/formats/openai.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/goose/src/providers/formats/openai.rs b/crates/goose/src/providers/formats/openai.rs index 937d9658ffde..34cf33fc84f8 100644 --- a/crates/goose/src/providers/formats/openai.rs +++ b/crates/goose/src/providers/formats/openai.rs @@ -512,11 +512,8 @@ where } } } - } else { - done = true; } - - if tool_chunk.choices[0].finish_reason == Some("tool_calls".to_string()) { + if tool_chunk.choices[0].finish_reason.is_some() { done = true; } } else {