fix: stream internal model calls with idle timeouts (#5730)
* fix: stream internal model calls with idle timeouts * fix(providers): reject streams without terminal events
This commit is contained in:
1 parent
aeb7b207d7
commit
73410e0217
60 files changed
+815
-795
No files matched your search
@@ -106,7 +106,7 @@ async def test_runner_preserves_reasoning_fields_in_assistant_history():
|
||||
captured_second_call: list[dict] = []
|
||||
call_count = {"n": 0}
|
||||
|
||||
async def chat_with_retry(*, messages, **kwargs):
|
||||
async def chat_stream_with_retry(*, messages, **kwargs):
|
||||
call_count["n"] += 1
|
||||
if call_count["n"] == 1:
|
||||
return LLMResponse(
|
||||
@@ -119,7 +119,7 @@ async def test_runner_preserves_reasoning_fields_in_assistant_history():
|
||||
captured_second_call[:] = messages
|
||||
return LLMResponse(content="done", tool_calls=[], usage=None)
|
||||
|
||||
provider.chat_with_retry = chat_with_retry
|
||||
provider.chat_stream_with_retry = chat_stream_with_retry
|
||||
tools = MagicMock()
|
||||
tools.get_definitions.return_value = []
|
||||
tools.execute = AsyncMock(return_value="tool result")
|
||||
@@ -152,7 +152,7 @@ async def test_runner_emits_anthropic_thinking_blocks():
|
||||
|
||||
provider = MagicMock()
|
||||
|
||||
async def chat_with_retry(**kwargs):
|
||||
async def chat_stream_with_retry(**kwargs):
|
||||
return LLMResponse(
|
||||
content="The answer is 42.",
|
||||
thinking_blocks=[
|
||||
@@ -163,7 +163,7 @@ async def test_runner_emits_anthropic_thinking_blocks():
|
||||
usage=LLMUsage.reported(input_tokens=5, output_tokens=3),
|
||||
)
|
||||
|
||||
provider.chat_with_retry = chat_with_retry
|
||||
provider.chat_stream_with_retry = chat_stream_with_retry
|
||||
tools = MagicMock()
|
||||
tools.get_definitions.return_value = []
|
||||
|
||||
@@ -192,14 +192,14 @@ async def test_runner_emits_inline_think_content_as_reasoning():
|
||||
|
||||
provider = MagicMock()
|
||||
|
||||
async def chat_with_retry(**kwargs):
|
||||
async def chat_stream_with_retry(**kwargs):
|
||||
return LLMResponse(
|
||||
content="<think>Let me think about this...\nThe answer is 42.</think>The answer is 42.",
|
||||
tool_calls=[],
|
||||
usage=LLMUsage.reported(input_tokens=5, output_tokens=3),
|
||||
)
|
||||
|
||||
provider.chat_with_retry = chat_with_retry
|
||||
provider.chat_stream_with_retry = chat_stream_with_retry
|
||||
tools = MagicMock()
|
||||
tools.get_definitions.return_value = []
|
||||
|
||||
@@ -227,7 +227,7 @@ async def test_runner_prefers_reasoning_content_over_inline_think():
|
||||
|
||||
provider = MagicMock()
|
||||
|
||||
async def chat_with_retry(**kwargs):
|
||||
async def chat_stream_with_retry(**kwargs):
|
||||
return LLMResponse(
|
||||
content="<think>inline thinking</think>The answer.",
|
||||
reasoning_content="dedicated reasoning field",
|
||||
@@ -235,7 +235,7 @@ async def test_runner_prefers_reasoning_content_over_inline_think():
|
||||
usage=LLMUsage.reported(input_tokens=5, output_tokens=3),
|
||||
)
|
||||
|
||||
provider.chat_with_retry = chat_with_retry
|
||||
provider.chat_stream_with_retry = chat_stream_with_retry
|
||||
tools = MagicMock()
|
||||
tools.get_definitions.return_value = []
|
||||
|
||||
@@ -349,7 +349,7 @@ async def test_runner_closes_reasoning_stream_after_one_shot_response():
|
||||
|
||||
provider = MagicMock()
|
||||
|
||||
async def chat_with_retry(**kwargs):
|
||||
async def chat_stream_with_retry(**kwargs):
|
||||
return LLMResponse(
|
||||
content="answer",
|
||||
reasoning_content="hidden thought",
|
||||
@@ -357,7 +357,7 @@ async def test_runner_closes_reasoning_stream_after_one_shot_response():
|
||||
usage=LLMUsage.reported(input_tokens=5, output_tokens=3),
|
||||
)
|
||||
|
||||
provider.chat_with_retry = chat_with_retry
|
||||
provider.chat_stream_with_retry = chat_stream_with_retry
|
||||
tools = MagicMock()
|
||||
tools.get_definitions.return_value = []
|
||||
|
||||
|
||||
Reference in new issue
Block a user