fix: treat SSE stream without [DONE] as truncated (retry, no cache)

This commit is contained in:
2026-07-16 05:26:21 -04:00
parent 7cc6aa5b23
commit 200053fbdc
2 changed files with 31 additions and 0 deletions
+4
View File
@@ -578,6 +578,10 @@ class GovernedLLMClient:
else:
thinking_parts.append(text)
# 流耗尽但未收 [DONE] → 服务端截断,视为可重试的 SSE 异常(不写缓存/不当成功)
if not usage_sink.get("done"):
raise _SseAnomaly("truncated_no_done")
content = "".join(content_parts)
thinking = "".join(thinking_parts)
usage = usage_sink.get("usage", {})