fix(agent): deliver non-streamed finalization responses

This commit is contained in:
chengyongru
2026-07-23 13:16:47 +08:00
committed by chengyongru
parent 536e8db324
commit 5f054c0e74
3 changed files with 85 additions and 5 deletions
+8 -1
View File
@@ -512,7 +512,7 @@ async def test_ssrf_soft_block_can_finalize_after_streamed_tool_call(tmp_path):
)],
usage={},
)
provider.chat_stream_with_retry = AsyncMock(side_effect=[
responses = iter([
tool_call_resp,
LLMResponse(
content="I cannot access private URLs. Please share the local file.",
@@ -521,6 +521,13 @@ async def test_ssrf_soft_block_can_finalize_after_streamed_tool_call(tmp_path):
),
])
async def chat_stream_with_retry(*, on_content_delta, **kwargs):
response = next(responses)
await on_content_delta(response.content)
return response
provider.chat_stream_with_retry = AsyncMock(side_effect=chat_stream_with_retry)
loop = AgentLoop(bus=bus, provider=provider, workspace=tmp_path, model="test-model")
loop.tools.get_definitions = MagicMock(return_value=[])
loop.tools.prepare_call = MagicMock(return_value=(None, {}, None))