Commit 2d61cb6
fix: preserve empty-string text parts in A2A converter
Merge #5343
## Summary
Fixes #5341 — `convert_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`.
COPYBARA_INTEGRATE_REVIEW=#5343 from voidborne-d:fix/part-converter-empty-text dbb2f20
PiperOrigin-RevId: 9053709611 parent 784350d commit 2d61cb6
2 files changed
Lines changed: 18 additions & 1 deletion
File tree
- src/google/adk/a2a/converters
- tests/unittests/a2a/converters
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
300 | 317 | | |
301 | 318 | | |
302 | 319 | | |
| |||
0 commit comments