Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/google/adk/a2a/converters/part_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def convert_genai_part_to_a2a_part(
) -> Optional[a2a_types.Part]:
"""Convert a Google GenAI Part to an A2A Part."""

if part.text:
if part.text is not None:
a2a_part = a2a_types.TextPart(text=part.text)
if part.thought is not None:
a2a_part.metadata = {_get_adk_metadata_key('thought'): part.thought}
Expand Down
23 changes: 20 additions & 3 deletions tests/unittests/a2a/converters/test_part_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,23 @@ def test_convert_text_part_with_thought(self):
assert result.root.metadata is not None
assert result.root.metadata[_get_adk_metadata_key("thought")]

def test_convert_empty_text_part(self):
"""Test that Part(text='') is preserved, not dropped.

Regression test for #5341: empty-string text parts are valid and
must not fall through to the unsupported-part warning.
"""
# Arrange
genai_part = genai_types.Part(text="")

# Act
result = convert_genai_part_to_a2a_part(genai_part)

# Assert — should produce a valid TextPart, not None
assert result is not None
assert isinstance(result.root, a2a_types.TextPart)
assert result.root.text == ""

def test_convert_file_data_part(self):
"""Test conversion of GenAI file_data Part to A2A Part."""
# Arrange
Expand Down Expand Up @@ -926,9 +943,9 @@ def test_a2a_function_call_with_thought_signature_to_genai(self):
_get_adk_metadata_key(
A2A_DATA_PART_METADATA_TYPE_KEY
): A2A_DATA_PART_METADATA_TYPE_FUNCTION_CALL,
_get_adk_metadata_key("thought_signature"): (
base64.b64encode(b"restored_signature").decode("utf-8")
),
_get_adk_metadata_key("thought_signature"): base64.b64encode(
b"restored_signature"
).decode("utf-8"),
},
)
)
Expand Down
Loading