Repository navigation
Description
[Bug]: DocumentBlock is silently dropped by most provider formatters, history paths, and text sinks
Describe the bug
#3869 introduced DocumentBlock for DashScope fileid:// inputs and #2275 added native
Anthropic PDF support, but the block is handled almost nowhere else. A document can reach a
model on one request and silently disappear when the conversation history is reformatted,
merged, compacted, exported, or delivered through another protocol. Some paths log an
unsupported-block warning, others reduce an attachment-only turn to empty text, and a few
reject the request outright.
Observed on main at 9e98dfa7
| Location (class) | Symptom |
|---|---|
OllamaChatFormatter, OllamaMessageConverter, OllamaConversationMerger, OllamaMultiAgentFormatter |
Documents dropped everywhere, including tool outputs; a document-only user turn disappears entirely. |
OpenAIConversationMerger, OpenAIMessageConverter (GLM/DeepSeek/Kimi/MiniMax inherit these) |
A user placeholder can survive direct formatting but vanishes during merging; assistant-carried documents have no text reference. |
ResponsesRequestMapper, ResponsesMultiAgentFormatter (OpenAI Official) |
Document input throws an unsupported-block exception; merged history omits the block. |
GeminiMessageConverter, GeminiMediaConverter, GeminiConversationMerger |
No document branch at all, despite Gemini's native document support. |
DashScopeMessageConverter, DashScopeConversationMerger |
Text conversion and merged history omit the reference, even though the separate fileid:// system message still sends the file. |
AbstractBaseFormatter.convertToolResultToString (shared) |
The block dispatch has no document branch, so tool-result documents are skipped. |
ConversationCompactor, MemoryFlushManager (harness) |
Documents, including those inside tool results, never reach the summarization/memory model. |
CommittedSessionEventProjector, SessionTranscriptExport |
Public session events omit documents; exports can contain empty message text or raw tool-result JSON. |
AguiMessageConverter (AG-UI) |
Outbound history omits document content; inbound document parts are rejected. |
ContentBlockParserRouter (A2A) |
Non-media file parts are filtered out; outbound documents have no registered parser. |
SubAgentTool, AgentSpawnTool, ModelSummarizationStrategy, Mem0LongTermMemory/Bailian/ReMe, AgentScopeAdapter, AgentProtocolTaskStore, AttributesExtractors |
Text extraction reduces a document-only message to an empty string. |
To Reproduce
On the affected revision:
Msg user = Msg.builder()
.role(MsgRole.USER)
.content(DocumentBlock.builder()
.source(URLSource.builder()
.url("https://example.com/report.pdf")
.mimeType("application/pdf")
.build())
.name("report.pdf")
.build())
.build();
List<OllamaMessage> out = new OllamaChatFormatter().format(List.of(user));
// The document-only user turn is omitted from the request entirely.
Adding a question as a TextBlock keeps the turn, but the document still has no
representation in the payload. Two more repro shapes:
- A tool result containing a
DocumentBlockhits the shared tool-result text fallback and
loses the attachment (the block dispatch throws or skips it depending on the path). - An assistant message carrying a document from a direct tool return loses the attachment
when replayed as history on the next request.
Error messages
The failure is usually silent — there is no error to catch. Verified at 9e98dfa7 with a
direct probe against each path:
- A document-only user turn is dropped with no error: Ollama's formatter returns an empty
request message list. - The shared tool-result text fallback (
convertToolResultToString) returns an empty
string for a document block, and message-level text extraction keeps only the surrounding
text, so a"reply"turn carrying a document loses the attachment without any warning
surface beyond the per-path debug logs. - The OpenAI Official Responses mapper rejects the request outright:
OpenAIOfficialModelException: Unsupported content block in user message: DocumentBlock
(and the assistant-message variant).
Expected behavior
- A document survives every hop of the conversation lifecycle: formatting for every
provider, history merging, compaction, memory flushing, exports, public events, telemetry,
and the AG-UI/A2A protocol boundaries. Native provider support (Anthropic PDF today,
Gemini file data) should keep working and be extended where a supported source and MIME
type exists. - Where a provider cannot carry the file, the turn keeps a visible one-line text reference
containing the name, the MIME type when known, and the URL or provider file id — never the
base64 payload and never a local temp-file path. - Attachment-only turns must not be filtered out or exported as empty strings.
Environment (please complete the following information):
- AgentScope-Java Version: 2.1.0-SNAPSHOT (
9e98dfa7) - Java Version: 17
- OS: OS-independent (all provider formatters affected)
Known related limitations (reported for completeness, not part of the expected fix)
- The DashScope
doc_urllimit counts URL entries across the full reformatted history;
repeated URLs count again, and compaction is not guaranteed to run before the 10-entry
limit is reached. Historicalfileid://system references are resent on each request. - References rendered into span attributes can contain document names and signed URL
queries; query-string redaction remains a telemetry policy decision. ContextTokenEstimatorassigns a flat token cost to non-text blocks, which can undercount
a large PDF in budget decisions.
Additional context
This affects existing document workflows, including #3869, and was found while preparing
#3943 (DashScope doc_url input and PPT output, which will close in the same change).
The bug report concerns propagation; the DashScope feature surface is described by #3943.
Activity