Repository navigation
feat(core): add DocumentBlock and DashScope qwen-long document input - #3869
Merged
Merged
Conversation
Document input had no first-class representation. DataBlock carries bytes
but not document semantics, so converters could only route it as image,
audio or video; anything else was dropped.
DocumentBlock ("document") carries id, name, an optional MIME type and
optional provider metadata, with FileIdSource ("file_id") as a new source
for documents that already live on the provider side.
USER messages accept the block; SYSTEM still accepts text only.
qwen-long reads documents from a fileid:// reference carried by a system message, not from a content part. Emit one system message per document block ahead of the turn that carries it, and keep the injected message out of automatic cache_control placement so the directive list stays aligned. URL and base64 document sources are rejected with an explicit error rather than silently dropped. The file upload client stays out of scope.
Both converters ignored blocks they did not recognise, and an all-document message collapsed to empty content - Anthropic dropped the message entirely. Emit a warning and a text placeholder so the caller can see that the document did not reach the model.
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
Role validation lets ASSISTANT/TOOL carry arbitrary blocks for back-compat, and the formatter was mapping a document block there too. Restrict the fileid:// injection and the source rejection to USER turns; a document on any other turn is aberrant input and is now ignored instead of being injected into the request. Also refresh the stale block list in the UserMessage javadoc.
jujn
approved these changes
Oct 31, 2026
This was referenced Nov 2, 2026
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
Description
Fixes #3865.
Background. Document input had no first-class representation.
DataBlockcarries bytes but no document semantics, and the converters route it as image / audio / video, so a PDF either became placeholder text or disappeared without a trace.Changes
DocumentBlock("document") withid/name/mimeType/ optional provider metadata, andFileIdSource("file_id") as a newSourcesubtype for documents that already live on the provider side. Registered in theContentBlocksubtype list and thesealed ... permitsclause;USERmessages accept the block,SYSTEMstill accepts text only. Docs block table updated indocs/v2/{en,zh}.{"role":"system","content":"fileid://<id>"}ahead of the turn that carries the document, which is the qwen-long contract. The injected message is excluded from automaticcache_controlplacement so the directive list stays aligned. URL and base64 sources are rejected with an explicit error rather than dropped. No model allowlist: an unsupported model surfaces the provider error instead of a list that goes stale.Scope. The file upload client,
qwen-doc-turbodoc_url, and document parsing / RAG / citations stay out of scope, as agreed in the issue. Multi-agent conversation paths are unchanged across providers (DashScopeMultiAgentFormatterand the per-provider conversation mergers): they merge history into a single prompt, a document block has no representation there yet, and blocks they do not know are already skipped silently - same as any block type added before this one.How to test
3500 tests, 0 failures. New coverage:
DocumentBlockTest(JSON round-trip of block and source, generated id, role validation),DashScopeChatFormatterTest(injected system message, rejected URL source, cache_control alignment), and a placeholder test in each converter.Four commits: the core block, the DashScope mapping and the converter placeholders can be reviewed or landed independently.
Checklist
mvn spotless:applymvn test)