@@ -90,20 +90,33 @@ async def test_translate_event_with_empty_parts(self, translator, mock_adk_event
90
90
91
91
@pytest .mark .asyncio
92
92
async def test_translate_function_calls_detection (self , translator , mock_adk_event ):
93
- """Test function calls detection and logging."""
94
- # Mock event with function calls
93
+ """Test function calls detection by asserting tool events are emitted.
94
+
95
+ This avoids brittle checks on debug log wording and instead
96
+ verifies that function calls result in ToolCall events.
97
+ """
98
+ # Mock event with one function call
95
99
mock_function_call = MagicMock ()
96
100
mock_function_call .name = "test_function"
101
+ mock_function_call .id = "call_123"
102
+ mock_function_call .args = {"param" : "value" }
97
103
mock_adk_event .get_function_calls = MagicMock (return_value = [mock_function_call ])
98
104
99
- with patch ('ag_ui_adk.event_translator.logger' ) as mock_logger :
100
- events = []
101
- async for event in translator .translate (mock_adk_event , "thread_1" , "run_1" ):
102
- events .append (event )
105
+ events = []
106
+ async for event in translator .translate (mock_adk_event , "thread_1" , "run_1" ):
107
+ events .append (event )
103
108
104
- # Should log function calls detection (along with the ADK Event debug log)
105
- debug_calls = [str (call ) for call in mock_logger .debug .call_args_list ]
106
- assert any ("ADK function calls detected: 1 calls" in call for call in debug_calls )
109
+ # Expect a START, ARGS, END sequence for the function call
110
+ types = [e .type for e in events ]
111
+ type_names = [str (t ).split ('.' )[- 1 ] for t in types ]
112
+ assert type_names == [
113
+ "TOOL_CALL_START" ,
114
+ "TOOL_CALL_ARGS" ,
115
+ "TOOL_CALL_END" ,
116
+ ]
117
+ # And the tool_call_id should match the mocked id
118
+ ids = [getattr (e , 'tool_call_id' , None ) for e in events ]
119
+ assert all (tc_id == "call_123" for tc_id in ids )
107
120
108
121
@pytest .mark .asyncio
109
122
async def test_translate_function_responses_handling (self , translator , mock_adk_event ):
@@ -781,4 +794,4 @@ async def test_partial_streaming_continuation(self, translator, mock_adk_event_w
781
794
782
795
# Should reset streaming state
783
796
assert translator ._is_streaming is False
784
- assert translator ._streaming_message_id is None
797
+ assert translator ._streaming_message_id is None
0 commit comments