Python: Fixed empty text content pydantic validation failure (#2539)

* Fixed empty text content pydantic validation failure

* simplify syntax. renamed test

---------

Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
This commit is contained in:
Hao Luo
2025-12-04 01:41:27 +00:00
committed by GitHub
co-authored by Evan Mattson
parent d774b64df0
commit b86c130411
2 changed files with 38 additions and 0 deletions
@@ -134,6 +134,13 @@ class AgentFrameworkEventBridge:
logger.info(f" Suppressed summary length={len(self.suppressed_summary)}")
return events
# Skip empty text chunks to avoid emitting
# TextMessageContentEvent with an empty `delta` which fails
# Pydantic validation (AG-UI requires non-empty strings).
if not content.text:
logger.info(" SKIPPING TextContent: empty chunk")
return events
if not self.current_message_id:
self.current_message_id = generate_event_id()
start_event = TextMessageStartEvent(