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:
chengyongru authored and GitHub committed 2026-09-11 13:06:43 +08:00
1 parent aeb7b207d7
commit 73410e0217
60 files changed
+815 -795

No files matched your search

+5 -5
View File
@@ -422,7 +422,7 @@ class TestSubagentCancellation:
call_count = {"n": 0}
async def scripted_chat_with_retry(*, messages, **kwargs):
async def scripted_chat_stream_with_retry(*, messages, **kwargs):
call_count["n"] += 1
if call_count["n"] == 1:
return LLMResponse(
@@ -433,7 +433,7 @@ class TestSubagentCancellation:
)
captured_second_call[:] = messages
return LLMResponse(content="done", tool_calls=[])
provider.chat_with_retry = scripted_chat_with_retry
provider.chat_stream_with_retry = scripted_chat_stream_with_retry
mgr = SubagentManager(
workspace=tmp_path,
bus=bus,
@@ -518,7 +518,7 @@ class TestSubagentCancellation:
bus = MessageBus()
provider = MagicMock()
provider.get_default_model.return_value = "test-model"
provider.chat_with_retry = AsyncMock(side_effect=[
provider.chat_stream_with_retry = AsyncMock(side_effect=[
LLMResponse(
content="first attempt",
tool_calls=[
@@ -566,7 +566,7 @@ class TestSubagentCancellation:
assert args[3] == "recovered after tool failure"
assert args[5] == "ok"
assert calls["n"] == 2
assert provider.chat_with_retry.await_count == 3
assert provider.chat_stream_with_retry.await_count == 3
@pytest.mark.asyncio
async def test_cancel_by_session_cancels_running_subagent_tool(self, monkeypatch, tmp_path):
@@ -577,7 +577,7 @@ class TestSubagentCancellation:
bus = MessageBus()
provider = MagicMock()
provider.get_default_model.return_value = "test-model"
provider.chat_with_retry = AsyncMock(return_value=LLMResponse(
provider.chat_stream_with_retry = AsyncMock(return_value=LLMResponse(
content="thinking",
tool_calls=[ToolCallRequest(id="call_1", name="list_dir", arguments={"path": "."})],
))