Skip to content

Surface hosted URIContent as text over AG-UI instead of dropping it - #935

Merged
Quim Muntal (qmuntal) merged 1 commit into
microsoft:mainfrom
PratikDhanaveFork:agui-host-uricontent-as-text
Aug 28, 2026
Merged

Surface hosted URIContent as text over AG-UI instead of dropping it#935
Quim Muntal (qmuntal) merged 1 commit into
microsoft:mainfrom
PratikDhanaveFork:agui-host-uricontent-as-text

Conversation

@PratikDhanave

Copy link
Copy Markdown
Contributor

Problem

In provider/aguiprovider/hosting_events.go, contentToEvents handles TextContent, FunctionCallContent, FunctionResultContent and DataContent; anything else hits default: return nil, nil. hasTextLikeContent likewise ignores it, so no TEXT_MESSAGE_START is emitted either. A hosted agent that yields a message.URIContent therefore produces no SSE event at all — the content is silently lost.

This is a real path: the Gemini provider emits URIContent for generated file responses, so hosting a Gemini agent behind AG-UI drops them.

Fix

Add a *message.URIContent case that emits the URI as a text-message-content event, mirroring the DataContent default fallback (dataContentToEvents emits unknown media as text) and the sibling A2A hosting path (contentsToParts JSON-marshals unknown content rather than dropping it). URIContent is also counted in hasTextLikeContent so the TEXT_MESSAGE_START/END framing is produced.

Test

TestHandler_URIContentEmittedAsText hosts an agent yielding a URIContent and asserts the URI appears in the SSE body. Fails before the fix (only RUN_STARTED/RUN_FINISHED are emitted), passes after.

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.
Copilot AI lite review requested due to automatic review settings August 28, 2026 05:42
@PratikDhanave
PratikDhanave (PratikDhanave) requested a review from a team as a code owner August 28, 2026 05:42
@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 pending-auto-risk Automatic risk classification is in progress labels 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

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.URIContent as “text-like” content so TEXT_MESSAGE_START/END events are emitted.
  • Convert *message.URIContent to TEXT_MESSAGE_CONTENT events 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.

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

Copy link
Copy Markdown
Contributor

API Consistency Review — PR #935


Scope: user-visible behavior (SSE event emission), internal-only implementation
Changed Go contract: No exported APIs changed. The unexported functions contentToEvents and hasTextLikeContent in provider/aguiprovider/hosting_events.go are extended with a *message.URIContent case that emits the URI string as a TEXT_MESSAGE_CONTENT SSE event and counts it for TEXT_MESSAGE_START/END framing. Previously, URIContent was silently dropped.
Upstream evidence reviewed:

  • python/packages/ag-ui/agent_framework_ag_ui/_run_common.py_emit_text and related content-to-event helpers: no URIContent type or equivalent concept exists. Python uses a unified Content type whose .text field carries text; binary/URI payloads are not modeled separately at this layer.
  • python/packages/ag-ui/agent_framework_ag_ui/_event_converters.pyAGUIEventConverter.convert_event: handles TEXT_MESSAGE_CONTENT, TOOL_CALL_*, and TOOL_CALL_RESULT; no URI/file content concept.
  • No .NET AG-UI hosting layer found in microsoft/agent-framework; AG-UI hosting exists only in Go and Python SDKs at this time.

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. URIContent emitted by the Gemini provider) that do not exist in the Python or .NET implementations, which use a flatter unified Content abstraction. The strategy chosen — emit the URI as plain text, mirroring the existing DataContent unknown-media fallback and the A2A sibling path — is internally consistent and does not conflict with upstream semantics.

No exported Go API surface changed; the public-api-change label is not warranted. Adding parity-approved.

Generated by Go API Consistency Review Agent · sonnet46 · 43.2 AIC · ⌖ 4.16 AIC · ⊞ 6.4K ·

@github-actions github-actions Bot added the parity-approved Go API consistency review found no parity issues label Aug 28, 2026
@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Aug 28, 2026
Merged via the queue into microsoft:main with commit 186e47e Aug 28, 2026
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