Skip to content

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

Open
Hardik K (hardikkaurani) wants to merge 1 commit into
microsoft:mainfrom
hardikkaurani:fix/devui-reasoning-delta-none-fallback
Open

Hardik K (hardikkaurani) wants to merge 1 commit into
microsoft:mainfrom
hardikkaurani:fix/devui-reasoning-delta-none-fallback

Conversation

@hardikkaurani

Copy link
Copy Markdown

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
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 on lines +1192 to +1205
context = {"item_id": "item-1", "output_index": 0, "content_index": 0, "sequence": 0}
content = MagicMock()
content.text = None

event = await mapper._map_reasoning_content(content, context)
assert event.type == "response.reasoning_text.delta"
assert event.delta == ""


async def test_map_reasoning_content_with_valid_text(mapper: MessageMapper) -> None:
"""Test that TextReasoningContent with valid text maps delta properly."""
from unittest.mock import MagicMock

context = {"item_id": "item-1", "output_index": 0, "content_index": 0, "sequence": 0}

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.

Hardik K (@hardikkaurani) can you please address this issue?

This branch was successfully deployed

1 active deployment
github-app-auth — f0530b4d Deployed Oct 19, 2026 by hardikkaurani via team_check #7082
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

3 participants