From 540cfdf737fd878f87b57b00894fbfc58b97feaa Mon Sep 17 00:00:00 2001 From: Jinhyuk Kim Date: Wed, 22 Jul 2026 17:04:37 -0700 Subject: [PATCH] fix: populate function name in FunctionResponse parts Ensures function name is included when converting interaction steps and deltas into FunctionResponse parts. Unit tests have been updated to verify that the name field is correctly populated. PiperOrigin-RevId: 952413239 --- src/google/adk/models/interactions_utils.py | 2 ++ tests/unittests/models/test_interactions_utils.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/google/adk/models/interactions_utils.py b/src/google/adk/models/interactions_utils.py index 501a30ab..8f832b3a 100644 --- a/src/google/adk/models/interactions_utils.py +++ b/src/google/adk/models/interactions_utils.py @@ -630,6 +630,7 @@ def _convert_interaction_step_to_parts(step: Step) -> list[types.Part]: types.Part( function_response=types.FunctionResponse( id=step.call_id or '', + name=step.name, response=_function_result_to_response(step.result), ) ) @@ -1003,6 +1004,7 @@ def _handle_function_result( part = types.Part( function_response=types.FunctionResponse( id=delta.call_id or '', + name=delta.name, response=_function_result_to_response(delta.result), ) ) diff --git a/tests/unittests/models/test_interactions_utils.py b/tests/unittests/models/test_interactions_utils.py index 890e9852..24cc492f 100644 --- a/tests/unittests/models/test_interactions_utils.py +++ b/tests/unittests/models/test_interactions_utils.py @@ -824,11 +824,13 @@ class TestConvertInteractionOutputToParts: output = FunctionResultStep( type='function_result', call_id='call_123', + name='get_weather', result={'weather': 'Sunny'}, ) result_list = interactions_utils._convert_interaction_step_to_parts(output) result = result_list[0] if result_list else None assert result.function_response.id == 'call_123' + assert result.function_response.name == 'get_weather' assert result.function_response.response == {'weather': 'Sunny'} def test_function_result_output_preserves_none_values(self): @@ -1468,6 +1470,7 @@ class TestConvertInteractionEventToLlmResponse: delta={ 'type': 'function_result', 'call_id': 'call_9', + 'name': 'get_temperature', 'result': {'temp': 72}, }, ) @@ -1478,6 +1481,7 @@ class TestConvertInteractionEventToLlmResponse: assert result is not None part = result.content.parts[0] assert part.function_response.id == 'call_9' + assert part.function_response.name == 'get_temperature' assert part.function_response.response == {'temp': 72} assert len(state.parts) == 1