fix(formatter): preserve reasoning_content from ThinkingBlock in DashScopeMessageConverter#1285
Open
uuuyuqi wants to merge 1 commit intoagentscope-ai:mainfrom
Open
fix(formatter): preserve reasoning_content from ThinkingBlock in DashScopeMessageConverter#1285uuuyuqi wants to merge 1 commit intoagentscope-ai:mainfrom
uuuyuqi wants to merge 1 commit intoagentscope-ai:mainfrom
Conversation
…ScopeMessageConverter When Qwen3 and similar models operate in thinking mode, assistant messages contain reasoning_content (chain-of-thought reasoning) which is correctly parsed into ThinkingBlock internally. However, DashScopeMessageConverter did not write this back to the reasoning_content field when building DashScopeMessage DTOs for subsequent API calls, causing the model to lose its reasoning history in multi-turn conversations. Fix by extracting ThinkingBlock from assistant messages and setting its content as reasoning_content on the outgoing DashScopeMessage. Close agentscope-ai#1284 Change-Id: If5c2749e048d46cbbdbed64d7b8a867a52c8d5ea Co-developed-by: Cursor <noreply@cursor.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Description
When Qwen3 and similar models operate in thinking mode, assistant messages contain
reasoning_content(chain-of-thought reasoning). AgentScope correctly parses this intoThinkingBlockinternally viaDashScopeResponseParser.However,
DashScopeMessageConverterdid not preserve thisreasoning_contentwhen converting internalMsgobjects back toDashScopeMessageDTOs for subsequent API calls (i.e., as conversation history). The reasoning context was silently dropped, causing the model to lose its thinking history in multi-turn conversations.Root Cause
In
DashScopeMessageConverter.convertToSimpleContent(), there was no logic to extractThinkingBlockfrom the internalMsgand set it asreasoning_contenton the outgoingDashScopeMessage.Fix
For assistant messages, extract the first
ThinkingBlockand set its content asreasoning_contenton theDashScopeMessage.Builder:Changed files:
DashScopeMessageConverter.convertToSimpleContent()— extract and preservereasoning_contentfromThinkingBlockClose #1284
Checklist
mvn spotless:applymvn test)Made with Cursor