Enhance conversation history and runtime variable management
- 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.
This commit is contained in:
37
backend/tests/test_conversation_history.py
Normal file
37
backend/tests/test_conversation_history.py
Normal file
@@ -0,0 +1,37 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user