fix(core): enhanced backward compatibility for event types, improved DeepSeek message handling for reasoning content, and the addition of a generic DataBlock for binary content.#1485
Open
chickenlj wants to merge 10 commits into
Conversation
…1261) ## AgentScope-Java Version io.agentscope:agentscope-parent:pom:1.0.12-SNAPSHOT ## Description Closes #1005 This PR fixes a session-state consistency bug in ReActAgent when maxIters is reached with pending tool calls. What was wrong: - If an iteration ended at maxIters while there were unresolved ToolUseBlocks, the agent could leave memory with tool_use entries but no matching tool_result. - On the next user turn, validation throw failed. ## 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`) - [ ] Javadoc comments are complete and follow project conventions - [ ] Related documentation has been updated (e.g. links, examples, etc.) - [x] Code is ready for review --------- Co-authored-by: Fancy-hjyp <2594297576@qq.com>
#1323) When thinking mode is enabled and a user turn contains tool calls, all assistant messages in that turn must preserve their reasoning_content when sent back to the DeepSeek API in subsequent requests. Previously, reasoning_content was only kept for the current turn, causing HTTP 400 errors in multi-turn tool-calling scenarios. See: https://api-docs.deepseek.com/guides/thinking_mode#tool-calls Fixes #1281 ## AgentScope-Java Version 1.0.12-SNAPSHOT ## Description **Background:** DeepSeek's thinking mode requires `reasoning_content` to be preserved for all assistant messages within a user turn that contains tool calls. The original code only preserved it for the current turn, causing HTTP 400 errors in multi-turn tool-calling scenarios. **Changes:** - `applyDeepSeekFixes()`: Added segment-level tool call detection via `computeSegmentToolFlags()`. A segment is defined as messages between two consecutive user messages. If any message in a segment contains tool calls, all assistant messages in that segment are flagged to preserve their `reasoning_content`. - `fixMessage()`: Renamed parameter from `isCurrentTurn` to `needReasoning` to reflect that preservation is now determined by the segment analysis, not just the turn boundary. - Added `ReasoningPreservationTests` nested test class covering key scenarios: non-thinking mode fallback, multiple rounds with tool calls, mixed text/tool rounds, text-only messages in tool-call segments, and regression for text-only segments. ## Checklist - [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 - [ ] Related documentation has been updated - [x] Code is ready for review
## AgentScope-Java Version io.agentscope:agentscope-parent:pom:1.0.13-SNAPSHOT ## Description * Closes: #828 * Release telemetry tracer on shutdown ## 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`) - [ ] Javadoc comments are complete and follow project conventions - [ ] Related documentation has been updated (e.g. links, examples, etc.) - [x] Code is ready for review
…1460) qwen3.6-max-preview is a text-only model and should not be routed to the multimodal-generation API. Add a reverse exclusion in DashScopeHttpClient#isMultimodalModel and document the qwen3.6 reverse-exclusion rule in the method Javadoc. ## AgentScope-Java Version [The version of AgentScope-Java you are working on, e.g. 1.0.12, check your pom.xml dependency version or run `mvn dependency:tree | grep agentscope-parent:pom`(only mac/linux)] ## Description [Please describe the background, purpose, changes made, and how to test this PR] ## 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
…on test Add package-info.java for the upcoming permission/, workspace/, credential/, and tool/permission/ packages, plus a placeholder PermissionEngineTest that locks in the expected matrix and is disabled pending the engine implementation. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…mments Strip "Mirrors Python ...", "Aligned with Python ...", "Ground truth from Python implementation", and similar annotations from production and test sources so the Java code documents itself in its own terms. No behavioural or schema changes; identifiers, fixtures, and ground-truth literals are unchanged. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
# Conflicts: # agentscope-core/src/main/java/io/agentscope/core/event/AgentEventType.java # agentscope-core/src/main/java/io/agentscope/core/message/ContentBlock.java
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.
This pull request introduces several important improvements and compatibility updates across the core agent framework, especially around event type handling, message formatting, and content block extensibility. The most significant changes include enhanced backward compatibility for event types, improved DeepSeek message handling for reasoning content, and the addition of a generic
DataBlockfor binary content. Documentation and comments have also been updated for clarity and accuracy.Event type compatibility and extensibility:
AgentEventType.java: Added legacy alias support using@JsonAliasfor backward compatibility with older event names and provided a custom@JsonCreatorto resolve both canonical and legacy names. This ensures seamless deserialization of events from previous versions and external systems. [1] [2] [3] [4]DeepSeek formatter reasoning content logic:
DeepSeekFormatter.java: Refined the logic for preserving or removingreasoning_contentin DeepSeek messages. Now, reasoning content is preserved for segments with tool calls in "thinking mode," and only removed for segments without tool calls, improving alignment with expected model behavior. [1] [2] [3] [4] [5]Content block extensibility:
ContentBlock.java: Introduced theDataBlocktype as a generic binary data block, unifying support for image, audio, and video data. Updated Jackson annotations and type hierarchy to support this new block. [1] [2] [3]Agent iteration and summary behavior:
ReActAgent.java: When the maximum number of iterations is reached, any pending tool calls are now explicitly marked as cancelled with error results, improving transparency and downstream handling.Documentation and comment improvements:
These changes collectively improve framework robustness, cross-version compatibility, and developer clarity.