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
+91 -1
View File
@@ -10,10 +10,13 @@ from services.runtime_variables import DynamicVariableStore, prepare_dynamic_con
from services.test_runs.mock_tools import MockToolExecutor, TextClientToolPort
from services.test_runs.text_runner import (
_TextCaptureProcessor,
_opening_speech_from_message,
_resolve_startup_greeting,
_runtime_record_from_message,
_wait_for_startup,
_wait_for_quiescence,
)
from test_schemas import BatchRunCreate
from test_schemas import BatchRunCreate, BatchStartupResult
class FakeLLM:
@@ -126,6 +129,25 @@ class DebugAutoTestContractTests(unittest.TestCase):
"你好,测试用户",
)
def test_startup_result_exposes_real_runtime_records(self):
result = BatchStartupResult.model_validate(
{
"completed": True,
"runtimeRecords": [
{
"type": "workflow-event",
"eventId": "wfe_opening",
"event": "message_started",
}
],
}
)
self.assertEqual(
result.runtime_records[0]["event"],
"message_started",
)
def test_text_client_port_records_automatic_message_confirmation(self):
port = TextClientToolPort()
@@ -142,6 +164,51 @@ class DebugAutoTestContractTests(unittest.TestCase):
[{"title": "重要提示", "message": "请确认"}],
)
def test_confirmation_owned_speech_is_kept_as_startup_greeting(self):
self.assertEqual(
_resolve_startup_greeting(
"",
["您好,请先阅读弹窗。"],
),
"您好,请先阅读弹窗。",
)
self.assertEqual(
_resolve_startup_greeting(
"普通开场白",
["其他固定播报"],
),
"普通开场白",
)
self.assertEqual(
_resolve_startup_greeting(
"",
[],
),
"",
)
def test_only_prompt_opening_transcript_is_identified_as_greeting(self):
self.assertEqual(
_opening_speech_from_message(
{
"type": "transcript",
"content": "您好,请先阅读弹窗。",
"source": "prompt-opening-speech",
}
),
"您好,请先阅读弹窗。",
)
self.assertEqual(
_opening_speech_from_message(
{
"type": "transcript",
"content": "普通 Workflow 播报",
"source": "workflow-message-speech",
}
),
"",
)
class DebugAutoTestRuntimeTests(unittest.IsolatedAsyncioTestCase):
async def test_system_end_tool_keeps_real_lifecycle_in_text_tests(self):
@@ -180,6 +247,29 @@ class DebugAutoTestRuntimeTests(unittest.IsolatedAsyncioTestCase):
self.assertEqual(params.result["action"], "ending_call")
self.assertEqual(executor_holder["executor"].unmocked_calls, [])
async def test_text_capture_keeps_runtime_records_for_auto_test_ui(self):
event = {
"type": "workflow-event",
"eventId": "wfe_end",
"event": "conversation_end_requested",
"reason": "测试完成",
}
self.assertEqual(_runtime_record_from_message(event), event)
self.assertIsNone(
_runtime_record_from_message({"type": "call-end-state"})
)
self.assertIsNone(
_runtime_record_from_message(
{
"type": "workflow-event",
"eventId": "wfe_internal",
"event": "client_tool_completed",
"internalStage": True,
}
)
)
async def test_startup_waits_for_queued_entry_reply(self):
capture = _TextCaptureProcessor(LLMContext(messages=[]))