Skip to content

Commit 305d98e

Browse files
text content replace with reasoningcontent in sync
1 parent 10ecbb9 commit 305d98e

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/agentex/lib/adk/_modules/_pydantic_ai_sync.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ async def handle_message_send(params):
4646
)
4747

4848
from agentex.lib.utils.logging import make_logger
49+
from agentex.types.reasoning_content import ReasoningContent
4950
from agentex.types.task_message_delta import TextDelta
5051
from agentex.types.tool_request_delta import ToolRequestDelta
5152
from agentex.types.task_message_update import (
@@ -109,7 +110,7 @@ async def convert_pydantic_ai_to_agentex_events(
109110
110111
Mapping:
111112
PartStartEvent(TextPart) -> StreamTaskMessageStart(TextContent)
112-
PartStartEvent(ThinkingPart) -> StreamTaskMessageStart(TextContent) [reasoning channel]
113+
PartStartEvent(ThinkingPart) -> StreamTaskMessageStart(ReasoningContent)
113114
PartStartEvent(ToolCallPart) -> StreamTaskMessageStart(ToolRequestContent)
114115
PartDeltaEvent(TextPartDelta) -> StreamTaskMessageDelta(TextDelta)
115116
PartDeltaEvent(ThinkingPart..) -> StreamTaskMessageDelta(ReasoningContentDelta)
@@ -171,10 +172,12 @@ async def convert_pydantic_ai_to_agentex_events(
171172
yield StreamTaskMessageStart(
172173
type="start",
173174
index=message_index,
174-
content=TextContent(
175-
type="text",
175+
content=ReasoningContent(
176+
type="reasoning",
176177
author="agent",
177-
content="",
178+
summary=[],
179+
content=[],
180+
style="active",
178181
),
179182
)
180183
if event.part.content:

tests/lib/adk/test_pydantic_ai_sync.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
FunctionToolResultEvent,
2424
)
2525

26+
from agentex.types.reasoning_content import ReasoningContent
2627
from agentex.types.task_message_delta import TextDelta
2728
from agentex.types.tool_request_delta import ToolRequestDelta
2829
from agentex.types.task_message_update import (
@@ -118,6 +119,12 @@ async def test_thinking_emits_reasoning_deltas(self):
118119
out = await _collect(convert_pydantic_ai_to_agentex_events(_aiter(events)))
119120

120121
assert isinstance(out[0], StreamTaskMessageStart)
122+
# Thinking content opens a ReasoningContent start, not a TextContent one,
123+
# so the Start's content_type matches the ReasoningContentDelta updates
124+
# that follow. Mismatched types here would render thinking as a plain
125+
# text bubble (or break server-side accumulators) instead of a
126+
# collapsible reasoning block.
127+
assert isinstance(out[0].content, ReasoningContent)
121128
assert isinstance(out[1], StreamTaskMessageDelta)
122129
assert isinstance(out[1].delta, ReasoningContentDelta)
123130
assert out[1].delta.content_delta == "step 1..."

0 commit comments

Comments
 (0)