fix: emit reasoning role for AG-UI reasoning messages - #941
Conversation
There was a problem hiding this comment.
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"forREASONING_MESSAGE_STARTregardless of the agent update role. - Stop defaulting reasoning-message roles to
"assistant"in the hosting conversion path. - Strengthen
TestHandler_ReasoningContent_EmitsReasoningEventsto decode SSEdata: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.
This comment has been minimized.
This comment has been minimized.
2f04de7 to
74ac4c9
Compare
Go API Consistency ReviewScope: user-visible behavior (SSE protocol output) This PR is a protocol compliance fix. The AG-UI spec requires
|
Summary
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
The regression test was verified to fail before the production change with actual assistant and expected reasoning.