fix: treat SSE stream without [DONE] as truncated (retry, no cache)
This commit is contained in:
@@ -259,6 +259,33 @@ async def test_qwen_thinking_stripped():
|
||||
assert thinking2 == ""
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_truncated_stream_without_done_raises():
|
||||
"""SSE 流耗尽但未收 [DONE] → _SseAnomaly(进重试,不当成功)。"""
|
||||
from adapters.llm import _SseAnomaly
|
||||
|
||||
async def _lines():
|
||||
yield 'data: {"choices":[{"delta":{"content":"半"}}]}'
|
||||
# 无 data: [DONE] —— 模拟服务端截断
|
||||
|
||||
client = _build_client()
|
||||
with pytest.raises(_SseAnomaly):
|
||||
await client._consume_stream(_lines())
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_complete_stream_with_done_ok():
|
||||
"""正常带 [DONE] 的流不抛异常,正确累积 content。"""
|
||||
|
||||
async def _lines():
|
||||
yield 'data: {"choices":[{"delta":{"content":"完整"}}]}'
|
||||
yield "data: [DONE]"
|
||||
|
||||
client = _build_client()
|
||||
content, _thinking, _ttft, _gap, _usage = await client._consume_stream(_lines())
|
||||
assert content == "完整"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_parent_call_id_forwarded_to_telemetry():
|
||||
"""parent_call_id 和 session_id 正确传递到遥测记录。"""
|
||||
|
||||
Reference in New Issue
Block a user