[Bugfix][Frontend] Emit a content block for empty Anthropic completions (#46525)

Signed-off-by: EazyReal <8047065+EazyReal@users.noreply.github.com>
This commit is contained in:
Maxwill Lin
2026-06-24 00:04:26 +00:00
committed by GitHub
parent d86c66c981
commit e48f2aa4ca
2 changed files with 45 additions and 0 deletions
+6
View File
@@ -665,6 +665,12 @@ class AnthropicServingMessages(OpenAIServingChat):
)
content += [anthropic_tool_call]
# Anthropic's canonical shape for an empty completion is a single
# empty text block, not []. Some strict clients assume content[0]
# exists, so emit one here.
if not content:
content.append(AnthropicContentBlock(type="text", text=""))
result.content = content
return result