fix(openai): preserve system role in DeepSeek formatter#2189
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Correct fix — DeepSeek API actually supports system role, so the previous conversion to user was unnecessary and incorrect.
Findings
- [Info]
DeepSeekFormatter.java:167-180— Removed theisSystemcheck and simplified the builder to preserve original role. Clean. - [Info] Tests updated to verify system role preservation. Good regression coverage.
Verdict
Minimal, correct fix. LGTM.
Automated review by github-manager
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
Clean, focused bug fix for issue #2168. The DeepSeekFormatter was incorrectly rewriting system role messages to user despite DeepSeek's API supporting the system role natively. This PR correctly preserves the original system role while keeping DeepSeek-specific handling (name removal, reasoning_content cleanup) intact.
The fix is minimal and well-scoped: removes the isSystem variable, simplifies early-return conditions, and uses msg.getRole() directly. Both DeepSeekFormatter and DeepSeekMultiAgentFormatter (which delegates via applyDeepSeekFixes()) are fixed with a single change point. Tests and Javadoc are updated consistently.
This is a behavioral change — users who adapted to the old (incorrect) behavior may notice the difference. Consider noting it in the CHANGELOG.
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
Clean, focused bug fix for issue #2168. The DeepSeekFormatter was incorrectly rewriting system role messages to user despite DeepSeek's API supporting the system role natively. This PR correctly preserves the original system role while keeping DeepSeek-specific handling (name removal, reasoning_content cleanup) intact.
The fix is minimal and well-scoped: removes the isSystem variable, simplifies early-return conditions, and uses msg.getRole() directly. Both DeepSeekFormatter and DeepSeekMultiAgentFormatter (which delegates via applyDeepSeekFixes()) are fixed with a single change point. Tests and Javadoc are updated consistently.
This is a behavioral change — users who adapted to the old (incorrect) behavior may notice the difference. Consider noting it in the CHANGELOG.
AgentScope-Java Version
2.0.1-SNAPSHOT
Description
Fixes #2168.
DeepSeek's current API supports the
systemrole, butDeepSeekFormatterwas rewriting system messages touser. This changed the intended message semantics and made the formatter inconsistent with the API behavior.This PR:
systemrole inDeepSeekFormatterandDeepSeekMultiAgentFormatteroutput;reasoning_content;How to test
mvn -pl agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-openai -am \ -Dtest=DeepSeekFormatterTest,DeepSeekMultiAgentFormatterTest \ -Dsurefire.failIfNoSpecifiedTests=false test mvn -pl agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-openai -am verify mvn spotless:apply mvn spotless:checkChecklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)