Repository navigation
Description
Summary
Add first-class document input support to the AgentScope message model, and use DashScope qwen-long as the first provider implementation.
Background
The current model modules do not provide a stable contract for document-type multimodal input:
DataBlockcan carry arbitrary binary data, but it does not model document semantics such as MIME type, file name, provider file ID, parsing strategy, or upload state.- Most model converters route
DataBlockonly as image/audio/video. Non-media MIME types are ignored, converted to placeholder text, or rejected. - DashScope officially supports document understanding through
qwen-longandqwen-doc-turbo, but the semantics differ from ordinary multimodal content parts.
For long-term maintenance, a dedicated DocumentBlock is preferable to adding document-specific fields to DataBlock. DataBlock should remain a generic binary/media block, while documents should have an explicit message contract.
Goals
1. Add a core DocumentBlock
Introduce a new content block for document input.
Suggested minimal fields:
idnamemimeTypesource- optional provider-specific metadata
Suggested source types:
- URL source
- Base64 source
- external file source, such as a provider file ID
2. Support DashScope qwen-long document input
Use qwen-long as the first stable provider target.
For a DocumentBlock backed by a DashScope file ID, the DashScope formatter should map it to an additional system message:
{
"role": "system",
"content": "fileid://{FILE_ID}"
}This follows DashScope's official qwen-long document understanding contract.
3. Keep document input separate from tool calling
Document understanding should be implemented as model message input conversion, not as a DashScope tool.
qwen-long and qwen-doc-turbo do not support Function Calling, and wrapping document input as a tool would add unnecessary ReAct rounds, failure paths, and nondeterminism.
Non-goals
- Do not add generic document support to all model providers in this issue.
- Do not implement the DashScope file upload client in the first phase.
- Do not automatically migrate existing
DataBlockusage toDocumentBlock. - Do not implement
qwen-doc-turbodoc_urlsupport in the first phase. - Do not add document parsing, RAG ingestion, or citation extraction.
References
- Qwen-Long document understanding: https://help.aliyun.com/zh/model-studio/long-context-qwen-long
Activity
ningmao-hlyz commentedon Oct 30, 2026
Hi @jujn — I'd like to take this.
Phase-1 plan, scoped to the issue:
core: DocumentBlock ("document") + FileIdSource ("file_id") as a new Source subtype, rather than overloading URLSource; register it in the sealed ContentBlock permits / @JsonSubTypes, and let Msg#validateRoleContent accept it on USER messages.
dashscope: the formatter emits the additional {"role":"system","content":"fileid://{id}"} message before the turn that carries the document; Base64/URL sources are rejected with a clear message in phase 1. No model allowlist — an unsupported model surfaces the provider error instead of a list that goes stale.
openai / anthropic: both converters currently drop unrecognised blocks without a trace (an all-document message even becomes empty), so they get an explicit DocumentBlock warning; Gemini and Ollama already log one.
tests/docs: JSON round-trip for block + source, formatter tests for the injected system message and the rejected source (no network); the new block added to the block table in docs/v2/{en,zh}/docs/building-blocks/message-and-event.md.
Core and DashScope will be separate commits in one PR, so they can be reviewed or landed independently.
feat(core): add DocumentBlock and DashScope qwen-long document input (a…