Skip to content

fix(core): preserve multimodal content parts in DashScope tool result…#1213

Merged
LearningGp merged 22 commits into
agentscope-ai:mainfrom
zhsnddn:fix/DashScope-Formatter
May 11, 2026
Merged

fix(core): preserve multimodal content parts in DashScope tool result…#1213
LearningGp merged 22 commits into
agentscope-ai:mainfrom
zhsnddn:fix/DashScope-Formatter

Conversation

@zhsnddn

@zhsnddn zhsnddn commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

1.0.12-SNAPSHOT

Description

fix issue#1153
Problem reproduction:
From the image, we can see that the current processing method converts all modalities into text format and then concatenates them. This causes an issue where image URLs cannot be extracted correctly from the same modality.
debug2

Comparison with the OpenAI approach:
In the OpenAI approach, a modality check is added before extraction. As shown in the image, different types can be separated, which makes it possible to extract image URLs.
debug1

Implementation and idea:
The implementation borrows from OpenAI’s approach by adding modality detection and separation before processing. Due to inconsistencies between the DTO formats and OpenAI, the final output is structured according to the DashScopeMessage DTO format.
image

debug3 Edge Cases Handled:

Due to structural adjustments, the input format of Tool result has been modified in DashScopeChatFormatterGroundTruthTest and DashScopeMultiAgentFormatterGroundTruthTest.

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@zhsnddn zhsnddn requested a review from a team April 13, 2026 14:01
@CLAassistant

CLAassistant commented Apr 13, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Apr 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.04348% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...formatter/dashscope/DashScopeMessageConverter.java 63.04% 14 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@LearningGp

Copy link
Copy Markdown
Member
image

@zhsnddn

zhsnddn commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

@LearningGp done,DeploymentPropertiesTest.java没有引入assertNull导致main分支流水线报错

@zhsnddn zhsnddn requested a review from LearningGp April 28, 2026 08:42

@LearningGp LearningGp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LearningGp LearningGp merged commit b82c1b3 into agentscope-ai:main May 11, 2026
5 checks passed
liangxingguang pushed a commit to liangxingguang/agentscope-java that referenced this pull request May 21, 2026
…s instead of merging into text. (agentscope-ai#1213)

## AgentScope-Java Version
>1.0.12-SNAPSHOT

## Description

fix
[issue#1153](agentscope-ai#1153)
Problem reproduction:
From the image, we can see that the current processing method converts
all modalities into text format and then concatenates them. This causes
an issue where image URLs cannot be extracted correctly from the same
modality.
<img width="1386" height="393" alt="debug2"
src="https://github.com/user-attachments/assets/2b68b693-2254-498e-81ee-b96f1940295c"
/>

Comparison with the OpenAI approach:
In the OpenAI approach, a modality check is added before extraction. As
shown in the image, different types can be separated, which makes it
possible to extract image URLs.
<img width="1422" height="510" alt="debug1"
src="https://github.com/user-attachments/assets/506edbc1-4704-4bd8-ab87-3f495525e7ce"
/>

Implementation and idea:
The implementation borrows from OpenAI’s approach by adding modality
detection and separation before processing. Due to inconsistencies
between the DTO formats and OpenAI, the final output is structured
according to the DashScopeMessage DTO format.
<img width="707" height="462" alt="image"
src="https://github.com/user-attachments/assets/0d2f44cc-5c11-40ec-b837-85d0a2408d3e"
/>

<img width="1480" height="565" alt="debug3"
src="https://github.com/user-attachments/assets/15e5591c-4b2b-4b87-bef8-4e0e7f614af7"
/>
Edge Cases Handled:

Due to structural adjustments, the input format of Tool result has been
modified in DashScopeChatFormatterGroundTruthTest and
DashScopeMultiAgentFormatterGroundTruthTest.




## Checklist

Please check the following items before code is ready to be reviewed.

- [x]  Code has been formatted with `mvn spotless:apply`
- [x]  All tests are passing (`mvn test`)
- [x]  Javadoc comments are complete and follow project conventions
- [x] Related documentation has been updated (e.g. links, examples,
etc.)
- [x]  Code is ready for review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 工具返回多模态时Formatter不符合预期

3 participants