fix: stop replaying OpenAI stream text

Avoid replaying buffered text at the end of OpenAI streams so text-only responses are emitted once while forced tool fallback behavior stays intact.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
mmc
2026-04-25 15:20:13 +08:00
parent 109c34a8dc
commit 3c9d419726
2 changed files with 28 additions and 4 deletions

View File

@@ -650,9 +650,7 @@ async def v1_chat_completions(req: ChatCompletionsRequest, request: Request):
buffered_text_parts.clear()
yield f"data: {json.dumps(payload, ensure_ascii=False)}\n\n"
if buffered_text_parts:
for buffered_text in buffered_text_parts:
yield _text_payload(buffered_text)
if buffered_text_parts and forced_tool_name and saw_tool_call:
buffered_text_parts.clear()
done_payload = {