Skip to content

fix: preserve empty-string text parts in A2A converter#5343

Open
voidborne-d wants to merge 1 commit intogoogle:mainfrom
voidborne-d:fix/part-converter-empty-text
Open

fix: preserve empty-string text parts in A2A converter#5343
voidborne-d wants to merge 1 commit intogoogle:mainfrom
voidborne-d:fix/part-converter-empty-text

Conversation

@voidborne-d
Copy link
Copy Markdown

Summary

Fixes #5341convert_genai_part_to_a2a_part() drops Part(text='') because the truthiness check if part.text: treats empty strings as falsy.

Root Cause

Part(text='') is valid and is produced in at least two places in the ADK:

  1. code_executors/code_execution_utils.py — when code execution completes with None output
  2. models/interactions_utils.py — when the Interactions API returns None text content

Gemini 2.5 Flash (thinking mode) also emits empty text parts.

When the converter drops all parts the A2A message ends up with zero parts and the client sees "broken thinking" with no content.

Fix

Change line 182 from if part.text: to if part.text is not None: so that empty strings are correctly wrapped as TextPart while None is still skipped.

Test

Added test_convert_empty_text_part — verifies that Part(text='') produces a valid TextPart(text='') instead of returning None.

Part(text='') is valid — it is produced by code_execution_utils.py when
code execution returns None, and by interactions_utils.py when the
Interactions API returns None text. Gemini 2.5 Flash thinking mode also
emits empty text parts.

The truthiness check `if part.text:` treats '' as falsy, causing the
converter to skip the part entirely. When all parts in a response are
empty the A2A message ends up with zero parts and the client sees
"broken thinking" with no content.

Change the check to `if part.text is not None:` so that empty strings
are correctly wrapped as TextPart while None is still skipped.

Add a regression test for the empty-string case.

Fixes google#5341
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Part converter drops Part(text='') causing broken A2A responses

1 participant