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
This commit is contained in:
Jinhyuk Kim
2026-07-22 17:04:37 -07:00
committed by Copybara-Service
parent fab5347f56
commit 540cfdf737
2 changed files with 6 additions and 0 deletions
@@ -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),
)
)
@@ -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