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

@@ -24,7 +24,6 @@ def _make_loop(
provider.generation = GenerationSettings(max_tokens=max_tokens)
provider.estimate_prompt_tokens.return_value = (estimated_tokens, "test-counter")
_response = LLMResponse(content="ok", tool_calls=[])
provider.chat_with_retry = AsyncMock(return_value=_response)
provider.chat_stream_with_retry = AsyncMock(return_value=_response)
loop = AgentLoop(
@@ -64,7 +63,7 @@ async def test_runner_pressure_commits_summary_and_current_delta(tmp_path) -> No
return 100, "test-counter"
loop.provider.estimate_prompt_tokens.side_effect = estimate
loop.provider.chat_with_retry = AsyncMock(side_effect=[
loop.provider.chat_stream_with_retry = AsyncMock(side_effect=[
LLMResponse(content="Current checkpoint.", tool_calls=[]),
LLMResponse(content="done", tool_calls=[]),
])
@@ -72,8 +71,8 @@ async def test_runner_pressure_commits_summary_and_current_delta(tmp_path) -> No
result = await loop.process_direct("continue the task", session_key="cli:test")
assert result.content == "done"
assert loop.provider.chat_with_retry.await_count == 2
model_request = loop.provider.chat_with_retry.await_args_list[1].kwargs["messages"]
assert loop.provider.chat_stream_with_retry.await_count == 2
model_request = loop.provider.chat_stream_with_retry.await_args_list[1].kwargs["messages"]
assert "Current checkpoint." in model_request[0]["content"]
assert model_request[1]["content"] == SUMMARY_CONTINUATION_TEXT
assert model_request[2]["content"] == "continue the task"
@@ -110,7 +109,7 @@ async def test_native_provider_compaction_commits_portable_terminal_checkpoint(
payload={"items": [{"type": "compaction", "encrypted_content": "opaque"}]},
)
loop.provider.can_resume_conversation_state.return_value = True
loop.provider.chat_with_retry = AsyncMock(return_value=LLMResponse(
loop.provider.chat_stream_with_retry = AsyncMock(return_value=LLMResponse(
content="done",
provider_state=compacted_state,
provider_compaction_applied=True,