Skip to content

[Feature]: Support DocumentBlock and DashScope qwen-long document input #3865

Closed

Description

@jujn

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:

  • DataBlock can 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 DataBlock only as image/audio/video. Non-media MIME types are ignored, converted to placeholder text, or rejected.
  • DashScope officially supports document understanding through qwen-long and qwen-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:

  • id
  • name
  • mimeType
  • source
  • 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 DataBlock usage to DocumentBlock.
  • Do not implement qwen-doc-turbo doc_url support in the first phase.
  • Do not add document parsing, RAG ingestion, or citation extraction.

References

Activity

  1. added
    enhancement
    help wanted
    on Oct 30, 2026
  2. ningmao-hlyz commented on Oct 30, 2026

    @ningmao-hlyz
    Contributor

    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.

  3. added a commit that references this issue on Oct 31, 2026
    6ee8044
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementhelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions