Surface hosted URIContent as text over AG-UI instead of dropping it - #935
Conversation
contentToEvents handled TextContent, FunctionCall/ResultContent and DataContent; every other content type fell through to the default and produced no SSE event, and hasTextLikeContent ignored them so not even a TEXT_MESSAGE_START was emitted. A hosted agent that yields a URIContent - e.g. the Gemini provider, which emits URIContent for generated files - therefore had that content silently dropped. Emit the URI as a text-message-content event, mirroring the DataContent default fallback and the A2A hosting path, which JSON-marshal unknown content rather than dropping it. Count URIContent in hasTextLikeContent so the surrounding TEXT_MESSAGE_START/END framing is emitted.
There was a problem hiding this comment.
Pull request overview
Fixes AG-UI hosting so message.URIContent (e.g., Gemini-generated file URIs) is no longer silently dropped when streaming SSE events; instead it is surfaced to clients as text content and properly framed with TEXT_MESSAGE_START/END.
Changes:
- Treat
*message.URIContentas “text-like” content soTEXT_MESSAGE_START/ENDevents are emitted. - Convert
*message.URIContenttoTEXT_MESSAGE_CONTENTevents by emitting the URI string. - Add an end-to-end handler test that asserts the URI appears in the SSE response body.
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 | Adds URIContent handling in both framing detection (hasTextLikeContent) and event conversion (contentToEvents) to avoid dropping hosted URIs. |
| provider/aguiprovider/hosting_test.go | Adds coverage ensuring a hosted agent emitting URIContent results in the URI being present in the SSE payload. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
API Consistency Review — PR #935 Scope: user-visible behavior (SSE event emission), internal-only implementation
Result: aligned — no parity issues This PR is a Go-specific bug fix with no upstream equivalent to check against. The Go framework models provider-specific content types (e.g. No exported Go API surface changed; the
|
Problem
In
provider/aguiprovider/hosting_events.go,contentToEventshandlesTextContent,FunctionCallContent,FunctionResultContentandDataContent; anything else hitsdefault: return nil, nil.hasTextLikeContentlikewise ignores it, so noTEXT_MESSAGE_STARTis emitted either. A hosted agent that yields amessage.URIContenttherefore produces no SSE event at all — the content is silently lost.This is a real path: the Gemini provider emits
URIContentfor generated file responses, so hosting a Gemini agent behind AG-UI drops them.Fix
Add a
*message.URIContentcase that emits the URI as a text-message-content event, mirroring theDataContentdefault fallback (dataContentToEventsemits unknown media as text) and the sibling A2A hosting path (contentsToPartsJSON-marshals unknown content rather than dropping it).URIContentis also counted inhasTextLikeContentso theTEXT_MESSAGE_START/ENDframing is produced.Test
TestHandler_URIContentEmittedAsTexthosts an agent yielding aURIContentand asserts the URI appears in the SSE body. Fails before the fix (only RUN_STARTED/RUN_FINISHED are emitted), passes after.