Skip to content

Python: fix(devui): fallback to empty string when reasoning chunk has no text - #9546

Merged
Vincent Biret (baywet) merged 2 commits into
microsoft:mainfrom
hardikkaurani:fix/devui-reasoning-delta-none-fallback
Oct 22, 2026
Merged

Vincent Biret (baywet) merged 2 commits into
microsoft:mainfrom
hardikkaurani:fix/devui-reasoning-delta-none-fallback

Conversation

@hardikkaurani

Copy link
Copy Markdown
Contributor

Description

Fixes #9533: When running an agent with Gemini (or any client where a reasoning chunk has no text content), content.text can be None. In MessageMapper._map_reasoning_content (agent_framework_devui/_mapper.py), passing delta=content.text causes Pydantic to raise:

1 validation error for ResponseReasoningTextDeltaEvent
delta
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]

This PR:

  • Adds an empty string fallback delta=content.text or "" in _map_reasoning_content to ensure valid string input for ResponseReasoningTextDeltaEvent.
  • Adds unit tests in python/packages/devui/tests/devui/test_mapper.py covering reasoning content mapping with both None and valid text.

Fixes #9533

cc Vincent Biret (@baywet) westey (@westey-m)

This comment was marked as off-topic.

@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Oct 19, 2026
@github-actions github-actions Bot changed the title fix(devui): fallback to empty string when reasoning chunk has no text Python: fix(devui): fallback to empty string when reasoning chunk has no text Oct 19, 2026
@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Hi Vincent Biret (@baywet) westey (@westey-m), submitted this PR to address #9533 where reasoning chunks with no text content cause Pydantic validation failure in DevUI _map_reasoning_content. Added unit tests covering both None and valid text scenarios. Ready for your review, thank you!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Both new tests initialize the wrong sequence key and raise KeyError before reaching their assertions.

1 open issue

Review effort: Balanced

Comment thread python/packages/devui/tests/devui/test_mapper.py Outdated
@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Vincent Biret (@baywet) The requested test-context fix is now in 04baa1e. Both reasoning-content tests initialize sequence_counter correctly, and local Python 3.11 DevUI tests plus targeted prek checks pass. Thank you for the review.

@baywet Vincent Biret (baywet) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making the changes!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix addresses the reported failure, and the tests correctly initialize the required sequence counter.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@hardikkaurani

Copy link
Copy Markdown
Contributor Author

appreciated for the review Vincent Biret (@baywet)

@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Hi Vincent Biret (@baywet) , thank you for reviewing and approving the PR! All requested changes have been addressed, and the checks are passing. When you have a chance, could you please merge it? I appreciate your time and feedback.

@baywet

Copy link
Copy Markdown
Member

Hardik K (@hardikkaurani) while I have permissions to review and merge on the dotnet side, I don't have them on the python side.

Maybe Jose Alvarez (@jpalvarezl) can help here.

@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Thank you for clarifying, Vincent Biret (@baywet) ! I appreciate your help and the suggestion. I'll reach out to Jose for guidance on the Python side. Thanks again for your time and support!

@baywet
Vincent Biret (baywet) added this pull request to the merge queue Oct 22, 2026
Merged via the queue into microsoft:main with commit 4c191ff Oct 22, 2026
53 checks passed

This branch was successfully deployed

1 active deployment
github-app-auth — 04baa1e3 Deployed Oct 20, 2026 by hardikkaurani via add_label #25813
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: DevUI ResponseReasoningTextDeltaEvent fails when Gemini reasoning chunk has no text

4 participants