Repository navigation
feat(core,model,protocol,dashscope): preserve documents across the conversation lifecycle - #3979
Merged
jujn merged 5 commits intoNov 6, 2026
Conversation
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
ningmao-hlyz
force-pushed
the
fix/document-block-propagation
branch
from
November 4, 2026 18:11
299ce63 to
aa3a0fe
Compare
ningmao-hlyz
force-pushed
the
fix/document-block-propagation
branch
2 times, most recently
from
November 6, 2026 06:19
860134c to
6fbf466
Compare
Contributor
Author
|
@jujn could you review this when you get a chance? It closes #3943 and #3978 — DashScope Four commits, rebased on the latest |
Documents arriving in memory flushes, compaction summaries, subagent payloads, session exports, telemetry attributes, control-plane and admin projections used to be dropped or embedded as raw payloads. Introduce DocumentReferenceRenderer as the single renderer every text sink shares: blocks collapse to a one-line reference (URL, provider file id, or an inline-size description that never leaks base64 or a local temp path), and an attachment-only turn keeps its reference instead of being filtered out. Tool-result text conversion regains its DataBlock source path, and the session transcript export joins lines like Msg.getTextContent(), so blank lines survive leading, trailing, consecutive, and all-blank outputs. Documents without a name or id render as "unnamed" instead of "null".
Gemini, Ollama, OpenAI, and OpenAI Official formatters dropped or mangled documents in converter paths that never routed through the shared base extractor: assistant turns lost returnDirect tool deliveries, non-user roles silently discarded DocumentBlocks, and the Gemini MIME allowlist rejected document types the GenerateContent API actually accepts (markdown, TypeScript, notebooks, JSON, and more). Each provider now renders document references wherever documents can appear, Gemini maps accepted documents to its native fileData field and degrades the rest. The injected text extractor contract now excludes document references, and each converter renders one reference per document on top of it, so an assistant-carried document yields exactly one reference line through the real formatter entry point regardless of which extractor is injected.
The AG-UI protocol union had no way to express a document beyond a file handle, so URL and inline-data documents degraded to plain text and provider file handles lost their names and MIME types. Add a document content type with URL, data, and file sources; every source variant carries an optional name extension field, so a document's display name travels with the source and user metadata is never borrowed for transport. File handles map onto FileIdSource with the provider naming who issued the handle. On the A2A side, file parts and document-bearing metadata now parse back into DocumentBlocks: the parser router recognizes file parts, framework markers take precedence over user metadata keys without eating them, and a JSON-serialized block survives a round-trip as a reference instead of an opaque payload.
DashScope becomes the first provider with first-class document input: URL documents map onto the native doc_url content type with count and streaming validation, file-id documents ride the provider's file channel, and every formatter path (chat, multi-agent, converter) keeps document references instead of dropping them on assistant or tool turns. Document URLs and PPT-generation skills are declared through the DashScopeSkill DTO and marked in skill metadata, and the multimodal example plus the zh/en integration docs show the defaultOptions model default and the per-call form.
ningmao-hlyz
force-pushed
the
fix/document-block-propagation
branch
2 times, most recently
from
November 6, 2026 11:20
dfb35a2 to
22acc42
Compare
jujn
force-pushed
the
fix/document-block-propagation
branch
from
November 6, 2026 15:35
22acc42 to
386466c
Compare
jujn
approved these changes
Nov 6, 2026
This was referenced Nov 7, 2026
This was referenced Nov 20, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
2.1.0-SNAPSHOT (based on main at
7ad4939f)Description
Background
#3869 introduced
DocumentBlockand #2275 added native Anthropic PDF support, but the blockwas handled almost nowhere else: most provider formatters, the history merging/compaction
paths, exports, telemetry, and the AG-UI/A2A protocol boundaries dropped or mangled
documents, in several cases reducing an attachment-only turn to empty text or throwing an
unsupported-block exception. Details are in the linked issue. While fixing this, the
DashScope document surface described in #3943 (native
doc_urlinput and PPTskilloutput) is completed on the same propagation foundation.
What changed
fix(core): preserve document references in text sinks— newDocumentReferenceRendererrenders 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.
fix(model): preserve documents across provider formatting— Ollama, OpenAI (and theGLM/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.
feat(protocol): preserve documents through AG-UI and A2A— AG-UI gains a documentcontent type with URL / inline-data / provider-file sources.
Documents serialize on every role alongside the URL media support from feat(agui): convert URL media blocks to AG-UI input contents #4003 and compose
with the reasoning-plus-media split from fix(agui): preserve URL media alongside reasoning #4009; only a source the protocol cannot express
falls back to a text reference. A2A file parts parse back into
DocumentBlocks withframework metadata markers taking precedence over user keys.
feat(dashscope): support document inputs and PPT skills— closes [Feature]: Support qwen-doc-turbo document input and PPT output #3943: URLdocuments map to the native
doc_urlcontent part (count and streaming validation),file-id documents keep the
fileid://channel,file_parsing_strategyis honored, andthe PPT
skillparameter (template and creative mode) streams outline/pages throughthinking blocks with the download URL in the final text content and a typed
dashscope.skillmetadata marker. Multimodal example and zh/en docs included.fix(core,protocol,model): degrade unsupported documents instead of failing— adocument 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
unnamedinstead of leaking the block's internal UUID, A2Aleaves
FilePart.nameunset instead of shipping a UUID as the attachment name, and theA2A file parser validates the MIME type before a document marker can route around it.
How to test
mvn test— new unit tests cover the renderer, every provider converter/merger (includingformatter-entry tests that assert exactly-once reference rendering), AG-UI JSON round
trips (name survival, reserved-key conflicts, non-string values, no-name documents), A2A
parsing/metadata precedence, DashScope
doc_urlvalidation and skill DTOs, and blank-linefidelity in session exports.
doc_urlextraction with
qwen-doc-turboand creative-mode PPT generation with skill metadataannotation.
npm run check(432 pages, navigation/syntax/local links/anchors/assets) andthe docs script tests pass.
Closes #3943, closes #3978
Checklist
mvn spotless:applymvn test)