Python: Fixed empty text content pydantic validation failure#2539
Merged
moonbox3 merged 3 commits intomicrosoft:mainfrom Dec 4, 2025
Merged
Python: Fixed empty text content pydantic validation failure#2539moonbox3 merged 3 commits intomicrosoft:mainfrom
moonbox3 merged 3 commits intomicrosoft:mainfrom
Conversation
Member
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a Pydantic validation error that occurs when empty text deltas are emitted during streaming responses in the Python AzureAIClient. The AG-UI library validates that text message content events must have non-empty strings, so empty chunks need to be filtered out.
Key Changes:
- Added validation to skip empty text content chunks before emitting events
- Added test coverage for the empty text chunk scenario
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| python/packages/ag-ui/agent_framework_ag_ui/_events.py | Added empty string check in _handle_text_content to skip emitting events for empty text chunks |
| python/packages/ag-ui/tests/test_events_comprehensive.py | Added test_empty_text_message_streaming to verify empty chunks are properly skipped while maintaining message continuity |
moonbox3
approved these changes
Dec 4, 2025
dmytrostruk
approved these changes
Dec 4, 2025
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 2026
…ft#2539) * Fixed empty text content pydantic validation failure * simplify syntax. renamed test --------- Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Currently when using the Python
AzureAIClient, the streaming response will emit empty text deltas. When using it in conjunction with AG-UI, it results in a pydantic validation error.Description
Added a simple empty-string check, and if it's empty, skip adding the events to be emitted.
Contribution Checklist
Screenshots
Added "empty string" test case passes

cc. @lordlinus