Skip to content

feat(agui): convert URL media blocks to AG-UI input contents - #4003

Merged
jujn merged 2 commits into
agentscope-ai:mainfrom
dragondyt:feat/agui-url-media-to-input-contents
Nov 5, 2026
Merged

jujn merged 2 commits into
agentscope-ai:mainfrom
dragondyt:feat/agui-url-media-to-input-contents

Conversation

@dragondyt

@dragondyt dragondyt commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT

Description

Related to #551
Related to #3392

Complement the inbound multimodal path from #2518 by converting AgentScope URL media content blocks to AG-UI MessageContent.Blocks on the outbound path.

Changes

  • Map ImageBlock / AudioBlock / VideoBlock / DataBlock / DocumentBlock with URLSource to the matching AG-UI InputContent types (Image / Audio / Video / Document), preserving MIME type in metadata when present.
  • Keep plain-text messages on MessageContent.Text so existing wire format and getTextContent() remain unchanged.
  • Skip Base64 media sources on outbound conversion (URL-only for now).
  • Add regression tests covering media conversion, empty MIME metadata, Base64 skip, and text-only compatibility.
  • Update EN/ZH AG-UI docs to describe outbound URL media serialization.

Notes

Verification

  • mvn -T1C -pl agentscope-extensions/agentscope-extensions-protocol/agentscope-extensions-agui -am spotless:check test -Dtest=AguiMessageConverterTest

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@mintlify

mintlify Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 2444970.

Approve preview

@dragondyt

Copy link
Copy Markdown
Contributor Author

@jujn 辛苦有空的时候审核一下

@jujn
jujn merged commit dc077e7 into agentscope-ai:main Nov 5, 2026
7 checks passed
@dragondyt
dragondyt deleted the feat/agui-url-media-to-input-contents branch November 6, 2026 02:21
jujn pushed a commit that referenced this pull request Nov 6, 2026
## Description

Fixes #4008.

An assistant message with a `ThinkingBlock` and supported URL media, but
no text/tool call, currently converts to just a reasoning message.
`toSingleAguiMessage` collects the media, then its old reasoning-only
fast path returns before emitting it. This also loses media when
`toAguiMessageList` converts a conversation.

Build reasoning and standard content together in `buildAguiMessages`, as
suggested in review. Collect thinking, text, tool calls/results and
media in one content traversal, then emit the reasoning message and any
remaining content. The reasoning-only return requires the collected
media list to be empty, so mixed messages retain their assistant
`MessageContent.Blocks`. This removes `toSingleAguiMessage`,
`splitReasoningMessage` and the separate thinking scan while retaining
public entry points, message order and multiple-tool-result expansion.
The change builds on outbound media support in #4003 and is separate
from inbound document handling in #3392.

The regression covers all supported URL media categories (image, audio,
video, document, and image/document `DataBlock` routing), checking the
serialized type, URL and MIME type plus distinct generated message IDs.
A conversation-list case verifies media serialization and preservation
of the following user message; a reasoning-only control still yields one
reasoning message. EN/ZH protocol docs describe the mixed case.
jujn added a commit that referenced this pull request Nov 6, 2026
…nversation lifecycle (#3979)

## Description

### What changed

1. **`fix(core): preserve document references in text sinks`** — new
`DocumentReferenceRenderer` renders a document as a one-line reference
(name, MIME type,
URL/provider file id, or an inline-size description that never leaks
base64 or a local
temp path). Memory flushing, compaction, subagent/task results, session
exports, public
events, telemetry redaction, control-plane and admin projections now
keep that reference
   instead of losing the attachment.
2. **`fix(model): preserve documents across provider formatting`** —
Ollama, OpenAI (and the
GLM/DeepSeek/Kimi/MiniMax compat formatters), OpenAI Official Responses,
and Gemini keep
documents through formatting and merging; the text extractor contract is
"text without document references", and each converter renders
references where
documents can appear, so an assistant-carried document yields exactly
one reference
line. Gemini maps accepted MIME types (aligned with the GenerateContent
reference) to its
   native file data and degrades the rest.
3. **`feat(protocol): preserve documents through AG-UI and A2A`** —
AG-UI gains a document
   content type with URL / inline-data / provider-file sources.
Documents serialize on every role alongside the URL media support from
#4003 and compose
with the reasoning-plus-media split from #4009; only a source the
protocol cannot express
falls back to a text reference. A2A file parts parse back into
`DocumentBlock`s with
   framework metadata markers taking precedence over user keys.
4. **`feat(dashscope): support document inputs and PPT skills`** —
closes #3943: URL
documents map to the native `doc_url` content part (count and streaming
validation),
file-id documents keep the `fileid://` channel, `file_parsing_strategy`
is honored, and
the PPT `skill` parameter (template and creative mode) streams
outline/pages through
thinking blocks with the download URL in the final text content and a
typed
`dashscope.skill` metadata marker. Multimodal example and zh/en docs
included.
5. **`fix(core,protocol,model): degrade unsupported documents instead of
failing`** — a
document block stays in the conversation history, so a formatter that
throws on a source
it cannot deliver breaks every later turn of that session. DashScope now
emits a text
reference for Base64 payloads and file ids issued by another provider
(AG-UI accepts both
on input), references say `unnamed` instead of leaking the block's
internal UUID, A2A
leaves `FilePart.name` unset instead of shipping a UUID as the
attachment name, and the
A2A file parser validates the MIME type before a document marker can
route around it.

Co-authored-by: jujn <[email protected]>
jujn added a commit that referenced this pull request Nov 21, 2026
## Description

The AG-UI protocol defines three source types for media parts — `url`,
`data` (inline Base64), and `file` (provider-issued handle) — and the
inbound direction accepts all three. The outbound path from #4003,
however, serialized URL sources only: media blocks carrying a
`Base64Source` or `FileIdSource` were dropped silently, with no log or
fallback. Media sent as inline data or a file handle therefore
disappears from `MESSAGES_SNAPSHOT` history on reconnects, refreshes,
and session switches.

This change maps all three AgentScope source types on the outbound path,
mirroring the document handling #3979 established in
`toDocumentInputContent`.

Co-authored-by: jujn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants