feat: unify debug runtime timelines

This commit is contained in:
Xin Wang
2026-08-13 09:30:43 +08:00
parent 7c18cea16d
commit eb111a3890
21 changed files with 1380 additions and 533 deletions
+17 -1
View File
@@ -11,12 +11,27 @@ from pipecat.frames.frames import (
)
from services.pipecat.call_lifecycle import (
CallEndCoordinator,
call_end_trace_event,
playback_marker_for,
)
from services.pipecat.processors import CallEndingUserMuteStrategy
class CallEndCoordinatorTest(unittest.IsolatedAsyncioTestCase):
def test_shared_trace_event_uses_runtime_record_contract(self):
event = call_end_trace_event(
"pending",
reason="用户已完成咨询",
interruptible=True,
voice_interruptible=True,
)
self.assertEqual(event["type"], "workflow-event")
self.assertEqual(event["event"], "conversation_end_requested")
self.assertEqual(event["reason"], "用户已完成咨询")
self.assertTrue(event["interruptible"])
self.assertTrue(event["voiceInterruptible"])
async def asyncSetUp(self):
self.reasons: list[str] = []
self.states: list[tuple[str, bool]] = []
@@ -87,7 +102,7 @@ class CallEndCoordinatorTest(unittest.IsolatedAsyncioTestCase):
self.assertTrue(self.coordinator.accepts_input)
self.assertTrue(self.coordinator.cancel_pending_end())
await asyncio.sleep(0)
self.assertEqual(self.states[-1], ("cancelled", False))
self.assertEqual(self.states[-1], ("cancelled", True))
self.assertFalse(self.coordinator.ending)
self.assertTrue(self.coordinator.accepts_input)
self.assertTrue(self.coordinator.speaking)
@@ -95,6 +110,7 @@ class CallEndCoordinatorTest(unittest.IsolatedAsyncioTestCase):
await self.coordinator.observe(BotStoppedSpeakingFrame())
self.assertFalse(self.coordinator.speaking)
self.assertEqual(self.reasons, [])
self.assertEqual(self.coordinator.reason, "user_goodbye")
async def test_committed_end_rejects_cancellation(self):
self.coordinator.begin("required_shutdown")