fix: interrupt message output before tool result

This commit is contained in:
Xin Wang
2026-08-04 09:30:52 +08:00
parent d068927b53
commit a16ecd8e01
10 changed files with 152 additions and 37 deletions

View File

@@ -1,5 +1,6 @@
from __future__ import annotations
import asyncio
import unittest
from pipecat.frames.frames import BotStartedSpeakingFrame, BotStoppedSpeakingFrame
@@ -36,6 +37,20 @@ class CallEndCoordinatorTest(unittest.IsolatedAsyncioTestCase):
self.assertEqual(self.reasons, ["prompt_end_call"])
async def test_wait_until_silent_tracks_transport_boundary(self):
self.assertFalse(self.coordinator.speaking)
await self.coordinator.wait_until_silent()
await self.coordinator.observe(BotStartedSpeakingFrame())
self.assertTrue(self.coordinator.speaking)
wait_task = asyncio.create_task(self.coordinator.wait_until_silent())
await asyncio.sleep(0)
self.assertFalse(wait_task.done())
await self.coordinator.observe(BotStoppedSpeakingFrame())
await wait_task
self.assertFalse(self.coordinator.speaking)
async def test_tool_only_end_call_finishes_without_waiting(self):
self.coordinator.begin_response()
self.coordinator.begin("tool_only")