Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
17 changes: 17 additions & 0 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