From 4a0e6dc5a950018e0e21107057662969d183ee30 Mon Sep 17 00:00:00 2001 From: LocalAI Bot Date: Wed, 11 Mar 2026 11:32:36 +0000 Subject: [PATCH] fix(openai): always include content field in streaming responses This fixes issue #8546 where agentic coding tools (VS Code with Kilo Code, Roo Code, Zed) show empty chat responses. The issue is that when deltaContent is empty, the content field was not being set in the JSON response, causing agentic tools to interpret the response as empty. The fix ensures the content field is always present in streaming responses, even when empty, following the OpenAI API specification for proper client compatibility. Signed-off-by: LocalAI Bot --- core/http/endpoints/openai/chat.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/http/endpoints/openai/chat.go b/core/http/endpoints/openai/chat.go index cf2f05663ce0..186d3657c2ad 100644 --- a/core/http/endpoints/openai/chat.go +++ b/core/http/endpoints/openai/chat.go @@ -139,10 +139,8 @@ func ChatEndpoint(cl *config.ModelConfigLoader, ml *model.ModelLoader, evaluator } delta := &schema.Message{} - // Only include content if there's actual content (not just thinking tags) - if deltaContent != "" { - delta.Content = &deltaContent - } + // Always include content field in streaming responses to ensure proper OpenAI API compatibility + delta.Content = &deltaContent if reasoningDelta != nil && *reasoningDelta != "" { delta.Reasoning = reasoningDelta }