From 4f3a1215a048eb5fdb8f87f9c86309977ef80eb9 Mon Sep 17 00:00:00 2001 From: tejas ghatte Date: Mon, 18 May 2026 18:44:51 +0530 Subject: [PATCH] fix: emit role chunk from anthropic message start in chat stream --- core/providers/anthropic/chat.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/providers/anthropic/chat.go b/core/providers/anthropic/chat.go index d9431bba077..bdb2236ffba 100644 --- a/core/providers/anthropic/chat.go +++ b/core/providers/anthropic/chat.go @@ -1090,6 +1090,23 @@ func (chunk *AnthropicStreamEvent) ToBifrostChatCompletionStream(ctx *schemas.Bi switch chunk.Type { case AnthropicStreamEventTypeMessageStart: + if chunk.Message != nil && chunk.Message.Role != "" { + role := chunk.Message.Role + streamResponse := &schemas.BifrostChatResponse{ + Object: "chat.completion.chunk", + Choices: []schemas.BifrostResponseChoice{ + { + Index: 0, + ChatStreamResponseChoice: &schemas.ChatStreamResponseChoice{ + Delta: &schemas.ChatStreamResponseChoiceDelta{ + Role: &role, + }, + }, + }, + }, + } + return streamResponse, nil, false + } return nil, nil, false case AnthropicStreamEventTypeMessageStop: