Skip to content

Python: Fix AG-UI url source dropping attachments when the URL is in source.value - #7655

Open
Atharva Vichare (atty57) wants to merge 1 commit into
microsoft:mainfrom
atty57:atty57-7653
Open

Python: Fix AG-UI url source dropping attachments when the URL is in source.value#7655
Atharva Vichare (atty57) wants to merge 1 commit into
microsoft:mainfrom
atty57:atty57-7653

Conversation

@atty57

Copy link
Copy Markdown
Contributor

Motivation & Context

The ag-ui-protocol spec puts the URL of a url-typed source in source.value (InputContentUrlSource.value), not in source.url. _extract_multimodal_source_fields in the AG-UI message adapter only read source.url/source.uri for url-typed sources, so _parse_multimodal_media_part returned None and every attachment sent in the spec shape was silently dropped during the AG-UI → MAF conversion. Applications following the current AG-UI spec could not send file attachments at all.

The base64 branch immediately below already read source.value correctly, so the two branches disagreed about where the payload lives.

Description & Review Guide

  • What are the major changes?

    • _extract_multimodal_source_fields now reads source.value first for url-typed sources, keeping source.url/source.uri as fallbacks.
    • Docstring updated to describe both shapes.
    • Two tests added: the spec shape ({"type": "url", "value": ...}) and the non-spec url/uri shape, so the backward-compatible path stays covered.
  • What is the impact of these changes?

    • No behavior change for payloads that already worked: the legacy top-level url form and the non-spec source.url form both still resolve, and source.value only wins when it is present. Not a breaking change.
    • Attachments sent in the ag-ui-protocol shape now convert into a Content.from_uri(...) instead of being dropped.
  • What do you want reviewers to focus on?

    • Whether value should also take precedence in the unknown-source.type fallback branch. I left that branch alone: there value currently feeds data, and changing it would alter behavior for source types outside the spec. The spec only defines data and url sources, both using value, and both are now handled by their explicit branches.

Verification: uv run poe test -P ag-ui → 962 passed. The reproduction from the issue now yields a Content with uri == "https://example.com/files/document.pdf" and media_type == "application/pdf".

Related Issue

Fixes #7653

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

…source.value

The ag-ui-protocol `InputContentUrlSource` carries the URL in `source.value`,
but `_extract_multimodal_source_fields` only read `source.url`/`source.uri`
for url-typed sources, so attachments sent in the spec shape were dropped
during the AG-UI to MAF conversion. The base64 branch already read
`source.value` correctly.

Read `source.value` first, keeping `url`/`uri` as fallbacks for the non-spec
shape. Adds tests for both.

Fixes microsoft#7653
Copilot AI balanced review requested due to automatic review settings August 13, 2026 18:25
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Aug 13, 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 attachment conversion by recognizing spec-compliant URLs in source.value.

Changes:

  • Prioritizes source.value for URL sources while preserving legacy fallbacks.
  • Adds tests for spec and legacy URL shapes.

Reviewed changes

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

File Description
python/packages/ag-ui/agent_framework_ag_ui/_message_adapters.py Extracts URLs from spec-compliant sources.
python/packages/ag-ui/tests/ag_ui/test_message_adapters.py Covers current and legacy URL fields.

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

@github-actions

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/ag-ui/agent_framework_ag_ui
   _message_adapters.py6204892%169–170, 179–181, 184, 187–191, 193–198, 201, 210–212, 215–218, 254, 422, 543–545, 602, 605, 607, 610, 613, 629, 646, 668, 768, 784–785, 856, 878, 948, 983–984, 1052, 1095
TOTAL45879423990% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
9348 36 💤 0 ❌ 0 🔥 2m 32s ⏱️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: AG-UI InputContent in Messages Lost During Conversion Due to source.value Not Being Checked

3 participants