feat: 支持通过 GenerateOptions 按轮次动态控制 enableThinking#1494
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
7678f11 to
6e4cdb7
Compare
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR cleanly adds a per-request enableThinking override on GenerateOptions and wires it into DashScopeChatModel.applyThinkingMode, falling back to the model-level value when null. The merge logic and Javadocs are consistent with the rest of the file. However, the change introduces a behavioral gap: the model's stream flag (and the "thinking requires streaming" override) is resolved only at construction time from the model-level enableThinking. When a hook turns thinking on per-request while the model was built with stream=false and enableThinking=null/false, the request is sent in non-streaming mode, which the existing code explicitly warns is invalid. A minor symmetry issue exists for the inverse case (per-request enableThinking=false combined with a default thinkingBudget), which now produces a confusing validation error. The change is also untested.
Add enableThinking field to GenerateOptions so that hooks can dynamically control enable_thinking on a per-turn basis, not just thinking_budget. DashScopeChatModel.applyThinkingMode() now prioritizes the options-level value over the model-level fixed value, with full backward compatibility.
8eec87a to
90c0054
Compare
- [major] Add stream validation: throw when per-request enableThinking=true but model stream=false - [minor] Only throw on thinkingBudget when enableThinking is null (not configured); silently ignore when explicitly false - [minor] Remove 'via hooks' qualifier from Javadoc - [nit] Add unit tests for per-request override, stream validation, explicitly-disabled-with-budget, and mergeOptions enableThinking
825b052 to
3d752e6
Compare
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
All previously raised review comments have been addressed.
|
Run 'mvn spotless:apply' to fix these violations. |
a1eab38 to
f84fb58
Compare

改动说明
为
GenerateOptions新增enableThinking字段,使 Hook 能够按轮次动态控制enable_thinking(此前只能控制thinking_budget)。修改内容
GenerateOptions:新增enableThinking字段、getter、Builder 方法及 mergeOptions 合并逻辑DashScopeChatModel.applyThinkingMode():优先取 options 级别的值,未设置时 fallback 到模型级别的固定值向后兼容
完全向后兼容。当
options.getEnableThinking()为 null 时,行为与改造前一致,使用模型级别的this.enableThinking。