- Update ConversationRecorder to include source and nodeId metadata in transcripts for better context tracking. - Introduce optional variable handling in DynamicVariableStore, allowing for unset variables to be rendered as empty without raising errors. - Refactor WorkflowBrain to apply turn configurations and manage interaction policies dynamically, improving agent responsiveness. - Implement tests to ensure proper handling of updated session variables and workflow metadata in various scenarios.
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
from unittest.mock import AsyncMock
|
|
|
|
from services.conversation_history import ConversationRecorder
|
|
|
|
|
|
class ConversationRecorderTest(unittest.IsolatedAsyncioTestCase):
|
|
async def test_fixed_reply_transcript_keeps_workflow_metadata(self):
|
|
recorder = ConversationRecorder("conv_test")
|
|
recorder._append = AsyncMock()
|
|
|
|
await recorder.record_transport_message(
|
|
{
|
|
"type": "transcript",
|
|
"role": "assistant",
|
|
"content": "请稍等,我正在处理。",
|
|
"timestamp": "2026-07-14T10:00:00+08:00",
|
|
"source": "workflow-fixed-reply",
|
|
"nodeId": "agent_service",
|
|
}
|
|
)
|
|
|
|
recorder._append.assert_awaited_once_with(
|
|
"assistant",
|
|
"请稍等,我正在处理。",
|
|
"2026-07-14T10:00:00+08:00",
|
|
{
|
|
"source": "workflow-fixed-reply",
|
|
"node_id": "agent_service",
|
|
},
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|