Skip to content

fix: emit reasoning role for AG-UI reasoning messages - #941

Merged
Quim Muntal (qmuntal) merged 2 commits into
microsoft:mainfrom
by291:fix/agui-reasoning-role
Aug 29, 2026
Merged

fix: emit reasoning role for AG-UI reasoning messages#941
Quim Muntal (qmuntal) merged 2 commits into
microsoft:mainfrom
by291:fix/agui-reasoning-role

Conversation

@by291

Copy link
Copy Markdown
Contributor

Summary

  • emit the protocol-defined reasoning role for REASONING_MESSAGE_START events
  • avoid forwarding the internal assistant response role into AG-UI reasoning messages
  • add a handler-level regression assertion over the emitted SSE payload

Problem

Agent response updates normally use the assistant role, including updates that contain TextReasoningContent. The AG-UI hosting conversion forwarded that role into REASONING_MESSAGE_START, producing role assistant.

AG-UI requires this event role to be the literal reasoning. Strict clients such as @ag-ui/client reject the current payload during schema validation. The protocol decision is also documented by ag-ui-protocol/ag-ui#1416.

Testing

  • go test ./...
  • go test -race ./...
  • go vet ./...

The regression test was verified to fail before the production change with actual assistant and expected reasoning.

@by291
by291 (by291) requested a review from a team as a code owner August 29, 2026 06:22
Copilot AI lite review requested due to automatic review settings August 29, 2026 06:22
@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 29, 2026
@github-actions github-actions Bot added the pending-auto-risk Automatic risk classification is in progress label Aug 29, 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

This PR fixes AG-UI hosting SSE output so REASONING_MESSAGE_START events always emit the protocol-defined role ("reasoning") rather than forwarding the agent update’s internal role (commonly "assistant"), and adds a regression assertion to prevent reintroducing the mismatch that breaks strict AG-UI clients.

Changes:

  • Emit role: "reasoning" for REASONING_MESSAGE_START regardless of the agent update role.
  • Stop defaulting reasoning-message roles to "assistant" in the hosting conversion path.
  • Strengthen TestHandler_ReasoningContent_EmitsReasoningEvents to decode SSE data: frames and assert the emitted role.

Reviewed changes

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

File Description
provider/aguiprovider/hosting_events.go Forces REASONING_MESSAGE_START role to the protocol role (reasoning).
provider/aguiprovider/hosting_test.go Adds a handler-level regression assertion that the SSE payload uses role: "reasoning" for reasoning start events.

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

@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 29, 2026
@github-actions

This comment has been minimized.

@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Aug 29, 2026
@github-actions github-actions Bot added size:xlarge More than 300 changed lines or 10 files pending-auto-risk Automatic risk classification is in progress and removed size:medium At most 100 changed lines across at most 5 files risk:medium Contained production impact requiring normal review depth labels Aug 29, 2026
@by291
by291 (by291) force-pushed the fix/agui-reasoning-role branch from 2f04de7 to 74ac4c9 Compare August 29, 2026 06:49
Merged via the queue into microsoft:main with commit f8bf17f Aug 29, 2026
38 checks passed
@github-actions github-actions Bot added size:medium At most 100 changed lines across at most 5 files and removed size:xlarge More than 300 changed lines or 10 files labels Aug 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Go API Consistency Review

Scope: user-visible behavior (SSE protocol output)
Changed Go contract: None (no exported API changes). The internal updatesToAGUIEvents function now emits role: "reasoning" (via aguiTypes.RoleReasoning) instead of forwarding the internal assistant role for REASONING_MESSAGE_START SSE events.
Upstream evidence reviewed: The AG-UI protocol specification (ag-ui-protocol/ag-ui#1416) is the normative reference for the REASONING_MESSAGE_START event role field. Searched microsoft/agent-framework for Python/.NET AG-UI SSE hosting equivalents — no matching implementation found; AG-UI hosting is currently Go-specific.
Result: Aligned — no parity issues found.

This PR is a protocol compliance fix. The AG-UI spec requires REASONING_MESSAGE_START to carry role: "reasoning"; the previous Go code incorrectly forwarded the internal assistant role. The fix matches the authoritative protocol contract. No exported Go API surface changed, so public-api-change label is not warranted. parity-approved label remains correct.

Generated by Go API Consistency Review Agent · sonnet46 · 15.4 AIC · ⌖ 4.99 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 29, 2026
@by291
by291 (by291) deleted the fix/agui-reasoning-role branch August 29, 2026 07:02
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