Skip to content

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
v2_devfrom
v2_dev_msg
Open

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
chickenlj wants to merge 10 commits into
v2_devfrom
v2_dev_msg

Conversation

@chickenlj
Copy link
Copy Markdown
Collaborator

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 DataBlock for 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 @JsonAlias for backward compatibility with older event names and provided a custom @JsonCreator to 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 removing reasoning_content in 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 the DataBlock type 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:

  • Various files: Updated and clarified Javadoc comments and documentation to accurately reflect logic and behavior, and to remove outdated Python-specific references. [1] [2] [3] [4] [5] [6] [7]

These changes collectively improve framework robustness, cross-version compatibility, and developer clarity.

Wzy19930507 and others added 10 commits May 21, 2026 10:45
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants