Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/packages/devui/agent_framework_devui/_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ async def _map_reasoning_content(self, content: Any, context: dict[str, Any]) ->
"""Map TextReasoningContent to ResponseReasoningTextDeltaEvent."""
return ResponseReasoningTextDeltaEvent(
type="response.reasoning_text.delta",
delta=content.text,
delta=content.text or "",
item_id=context["item_id"],
output_index=context["output_index"],
content_index=context["content_index"],
Expand Down
31 changes: 31 additions & 0 deletions python/packages/devui/tests/devui/test_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,3 +1179,34 @@ async def test_superstep_completed_event(mapper: MessageMapper, test_request: Ag
# superstep_completed event (type='superstep_completed') may not emit events (internal workflow signal)
# Just ensure it doesn't crash
assert isinstance(events, list)


# =============================================================================
# Reasoning Content Tests
# =============================================================================


async def test_map_reasoning_content_with_none_text(mapper: MessageMapper) -> None:
"""Test that TextReasoningContent with None text falls back to empty string without raising validation error."""
from unittest.mock import MagicMock

context = {"item_id": "item-1", "output_index": 0, "content_index": 0, "sequence_counter": 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_counter": 0}
content = MagicMock()
content.text = "Thinking through the steps..."

event = await mapper._map_reasoning_content(content, context)
assert event.type == "response.reasoning_text.delta"
assert event.delta == "Thinking through the steps..."
Loading