Skip to content

Surface AG-UI REASONING_MESSAGE_CHUNK events as reasoning content - #936

Merged
Quim Muntal (qmuntal) merged 3 commits into
microsoft:mainfrom
PratikDhanaveFork:agui-surface-reasoning-message-chunk
Aug 31, 2026
Merged

Surface AG-UI REASONING_MESSAGE_CHUNK events as reasoning content#936
Quim Muntal (qmuntal) merged 3 commits into
microsoft:mainfrom
PratikDhanaveFork:agui-surface-reasoning-message-chunk

Conversation

@PratikDhanave

Copy link
Copy Markdown
Contributor

Problem

The AG-UI client's onEvent switch (provider/aguiprovider/agui.go) handles ReasoningMessageContentEvent and TextMessageChunkEvent, but has no case for ReasoningMessageChunkEvent — the chunk-form encoding of reasoning that the AG-UI decoder also produces (decoder.go case EventTypeReasoningMessageChunk). A server that streams reasoning as REASONING_MESSAGE_CHUNK events therefore has its reasoning silently dropped (falls through to the default).

This is the reasoning counterpart of the already-handled TEXT_MESSAGE_CHUNK case.

Fix

Add a *aguiEvents.ReasoningMessageChunkEvent case that emits a message.TextReasoningContent from the chunk delta, reusing the last seen chunk MessageID when a chunk omits it — mirroring the existing TextMessageChunkEvent handling and the ReasoningMessageContentEvent mapping.

Test

TestAGUIAgentRun_SurfacesReasoningMessageChunkEvents streams two REASONING_MESSAGE_CHUNK events and asserts the concatenated reasoning is surfaced as TextReasoningContent. Fails before the fix (empty), passes after.

Note: TOOL_CALL_CHUNK is intentionally not addressed here — the AG-UI Go decoder has no case for it, so it never reaches the client.

The client onEvent switch handles ReasoningMessageContentEvent but not the
semantically equivalent ReasoningMessageChunkEvent, which the AG-UI decoder
also produces (decoder EventTypeReasoningMessageChunk). A server that streams
reasoning as chunk events therefore has its reasoning silently dropped.

Add a ReasoningMessageChunkEvent case that emits a TextReasoningContent,
reusing the last chunk MessageID for chunks that omit it - mirroring the
existing TextMessageChunkEvent handling and ReasoningMessageContentEvent.
Copilot AI lite review requested due to automatic review settings August 28, 2026 05:46
@PratikDhanave
PratikDhanave (PratikDhanave) requested a review from a team as a code owner August 28, 2026 05:46
@github-actions github-actions Bot added area:provider Changes files in the provider area area:provider/agui Changes files in the provider / agui area size:medium At most 100 changed lines across at most 5 files labels Aug 28, 2026
@github-actions github-actions Bot added the pending-auto-risk Automatic risk classification is in progress label Aug 28, 2026

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.

Pull request overview

Adds support in the AG-UI provider for streaming reasoning deltas sent as REASONING_MESSAGE_CHUNK events, so chunked reasoning is surfaced to collectors instead of being dropped.

Changes:

  • Handle *aguiEvents.ReasoningMessageChunkEvent in toolCallAccumulator.onEvent by emitting message.TextReasoningContent updates.
  • Add a unit test that streams reasoning chunk events and asserts the concatenated reasoning is surfaced.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
provider/aguiprovider/agui.go Adds a switch-case to map ReasoningMessageChunkEvent into TextReasoningContent response updates (with MessageID continuation logic).
provider/aguiprovider/agui_test.go Adds a test asserting chunked reasoning is collected and exposed as TextReasoningContent.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread provider/aguiprovider/agui.go
Comment thread provider/aguiprovider/agui_test.go

@qmuntal Quim Muntal (qmuntal) 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.

Fix copilot feedback.

@github-actions github-actions Bot added risk:medium Contained production impact requiring normal review depth parity-approved Go API consistency review found no parity issues and removed pending-auto-risk Automatic risk classification is in progress labels Aug 28, 2026
@github-actions

This comment has been minimized.

ReasoningMessageChunkEvent reused toolCallAccumulator.lastChunkMessageID,
which TextMessageChunkEvent also uses. A stream interleaving text and
reasoning chunks where a reasoning chunk omits MessageID would inherit the
last text chunk's MessageID (and vice versa), mixing reasoning into a text
message. Track a separate lastReasoningChunkMessageID, and add a test that
interleaves text and reasoning chunks with an omitted reasoning MessageID.
@github-actions github-actions Bot added pending-auto-risk Automatic risk classification is in progress and removed risk:medium Contained production impact requiring normal review depth labels Aug 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

API Consistency Review — PR #936

Scope: User-visible behavior (AG-UI client event handling)
Changed Go contract: No exported API surface changed. The internal toolCallAccumulator.onEvent switch gains a new *aguiEvents.ReasoningMessageChunkEvent case that emits message.TextReasoningContent from chunk deltas, mirroring the existing TextMessageChunkEventTextContent and ReasoningMessageContentEventTextReasoningContent patterns already present.
Upstream evidence reviewed:

  • python/packages/ag-ui/agent_framework_ag_ui/_event_converters.py — Python AG-UI client handles TEXT_MESSAGE_CONTENT but has no cases for TEXT_MESSAGE_CHUNK, REASONING_MESSAGE_CONTENT, or REASONING_MESSAGE_CHUNK. Python does not implement a streaming-chunk client path.
  • dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/ — .NET AGUI code is server-side only (ASP.NET Core hosting); no AG-UI client implementation exists in the upstream .NET tree.

Result: Aligned / no parity issues.

Neither Python nor .NET upstream ship an AG-UI client that consumes streaming chunk events, so there is no cross-repo equivalent to diverge from. The fix completes the symmetric event-handling set in the Go client (text chunk ↔ reasoning chunk) and aligns REASONING_MESSAGE_CHUNK handling with the framework-wide TextReasoningContent concept used consistently across all SDK implementations. The parity-approved label is appropriate; no public-api-change label is needed (no exported symbols were added or modified).

Generated by Go API Consistency Review Agent · sonnet46 · 44.8 AIC · ⌖ 7.84 AIC · ⊞ 6.4K ·

@github-actions github-actions Bot added risk:medium Contained production impact requiring normal review depth and removed pending-auto-risk Automatic risk classification is in progress labels Aug 31, 2026
@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Aug 31, 2026
Merged via the queue into microsoft:main with commit e1f5fcc Aug 31, 2026
34 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider/agui Changes files in the provider / agui area area:provider Changes files in the provider area parity-approved Go API consistency review found no parity issues risk:medium Contained production impact requiring normal review depth size:medium At most 100 changed lines across at most 5 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants