Skip to content

Commit fc90f09

Browse files
declan-scaleclaude
andcommitted
fix(openai): use ReasoningContent for reasoning stream Start events
convert_openai_to_agentex_events opened reasoning summary/content messages with a TextContent Start. On the migrated auto_send/Temporal path this regressed the prior behavior (which started reasoning with ReasoningContent), so consumers branching on the start event's content type render reasoning as plain text. The final persisted content is rebuilt from the reasoning deltas regardless, so this only affects the live stream envelope. Aligns with the codex/claude_code taps and the langgraph-sync converter, and matches what the openai conformance suite already treats as canonical. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7bcca10 commit fc90f09

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

src/agentex/lib/adk/providers/_modules/sync_provider.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from agentex import AsyncAgentex
3333
from agentex.lib.utils.logging import make_logger
3434
from agentex.lib.core.tracing.tracer import AsyncTracer
35+
from agentex.types.reasoning_content import ReasoningContent
3536
from agentex.types.task_message_delta import TextDelta
3637
from agentex.types.task_message_update import (
3738
StreamTaskMessageDone,
@@ -560,14 +561,20 @@ async def convert_openai_to_agentex_events(stream_response):
560561
item_id_to_index[item_id] = message_index
561562
item_id_to_type[item_id] = "reasoning_summary"
562563

563-
# Send a start event for this new reasoning summary message
564+
# Send a start event for this new reasoning summary message.
565+
# The start content must be ReasoningContent (not TextContent)
566+
# so consumers that branch on the start event's content type
567+
# render a reasoning/thinking indicator; the final persisted
568+
# content is rebuilt from the reasoning deltas regardless.
564569
yield StreamTaskMessageStart(
565570
type="start",
566571
index=item_id_to_index[item_id],
567-
content=TextContent(
568-
type="text",
572+
content=ReasoningContent(
573+
type="reasoning",
569574
author="agent",
570-
content="", # Start with empty content
575+
summary=[],
576+
content=[],
577+
style="active",
571578
),
572579
)
573580

@@ -604,14 +611,20 @@ async def convert_openai_to_agentex_events(stream_response):
604611
item_id_to_index[item_id] = message_index
605612
item_id_to_type[item_id] = "reasoning_content"
606613

607-
# Send a start event for this new reasoning content message
614+
# Send a start event for this new reasoning content message.
615+
# The start content must be ReasoningContent (not TextContent)
616+
# so consumers that branch on the start event's content type
617+
# render a reasoning/thinking indicator; the final persisted
618+
# content is rebuilt from the reasoning deltas regardless.
608619
yield StreamTaskMessageStart(
609620
type="start",
610621
index=item_id_to_index[item_id],
611-
content=TextContent(
612-
type="text",
622+
content=ReasoningContent(
623+
type="reasoning",
613624
author="agent",
614-
content="", # Start with empty content
625+
summary=[],
626+
content=[],
627+
style="active",
615628
),
616629
)
617630

0 commit comments

Comments
 (0)