fix(dashscope): forward structured response format#1865
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
Precise fix for DashScope request path dropping response_format. The forwarding logic in DashScopeToolsHelper.applyOptions() follows the established null-guard pattern and is symmetric across streaming/non-streaming paths. Tests cover the regression. Suggestion: add a json_object type test case alongside the existing json_schema coverage.
|
@chickenlj 麻烦你帮我审核一下,谢谢您 |
|
I independently reproduced this on Root cause confirmed: But forwarding the format alone (the approach in #1865) does not fix qwen-max — it converts the silent failure into a hard 400. After wiring i.e. the native DashScope endpoint only supports The only path that works for native DashScope (incl. qwen-max) is the fallback Suggested direction, relating the open PRs:
Net: Option 2 for DashScope + #1743 as the cross-provider safety net looks like the complete fix. Minimal reproductionReActAgent agent = ReActAgent.builder()
.name("AnalysisAgent")
.model(DashScopeChatModel.builder()
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.modelName("qwen-max").stream(true).enableThinking(false)
.formatter(new DashScopeChatFormatter())
.build())
.toolkit(new Toolkit())
.build();
Msg msg = agent.call(new UserMessage("Extract product requirements: Apple laptop, 16GB RAM, $2000, lightweight"),
ProductRequirements.class).block();
System.out.println(msg.hasStructuredData()); // false on current main; true once Option 2 applied |
AgentScope-Java Version
2.0.0-SNAPSHOT
Description
This PR fixes DashScope native structured output by forwarding
GenerateOptions.responseFormatintoDashScopeParameters.responseFormatduring request building.Before this change, the DashScope request path dropped
response_format, so structured-output calls could not be parsed correctly andMsg.hasStructuredData()stayed false.Changes made:
responseFormatin DashScope option mappingHow to test:
mvn -pl agentscope-core -Dtest=DashScopeToolsHelperComprehensiveTest testChecklist