Repository navigation
Conversation
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
4 tasks
Buktal
marked this pull request as ready for review
October 26, 2026 03:12
…put cutoff Capture redacted_thinking payloads in the response parser and replay them as native redacted blocks instead of dropping them from history. Track every observed native block index, including metadata-only start/stop events, so a completed call before an empty block at the output cutoff stays executable instead of being rejected as malformed.
Keep native parallel tool-result batches while preserving is_error for failed, denied, and interrupted tool calls. Add coverage for mixed success and failure result batches.
Resolve conflicts with agentscope-ai#3852 in AnthropicResponseParser(.Test): keep this branch's native thinking signature/redacted-thinking replay and content-block metadata, and adopt main's finishReason handling (StopReason::asString wire value) in parseMessage and message_delta.
jujn
pushed a commit
that referenced
this pull request
Nov 8, 2026
## Problem Parallel client tool calls are rewritten into alternating assistant/user exchanges, and individual tool results are emitted as separate user messages. This changes the original tool batch structure and does not follow Anthropic's documented parallel result format. DeepSeek's official endpoint rejects separate result messages with HTTP 400 in the direct test below; the gateway-specific 502 reported in #4018 has not been reproduced. ## Changes - Preserve all tool uses in their original assistant message. - Group consecutive client tool results into one user message, placing results before accompanying text or media. - Keep server tool blocks inline and stop result grouping at conversation boundaries. - Update formatter/model comments and regression tests for separate/combined results, mixed text, multiple turns, and assistant messages carrying client tool results. - Use an explicit batch end index without rewinding the loop cursor; name accompanying content `trailingContent`. Fixes #4018. Related: #3740 includes broader native thinking/history replay changes; this PR focuses on parallel tool batch formatting.
This branch has not been deployed
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.
AgentScope-Java Version
2.1.0-SNAPSHOT
Description
Summary
Anthropic thinking signatures can be lost or attached to the wrong merged block, while parallel tool calls are rewritten as serial exchanges. Carry native content-block indices/completion and stop reasons through parsing and accumulation, then replay signed thinking blocks and parallel tool batches in their native shape.
Reuse existing accumulators and metadata. Keep real-time event aggregation and text middleware replacements/deletions/additions working, and remove transient block bookkeeping from stored message metadata. Completed native tool blocks remain distinguishable from empty starts cut off by the output limit.
Parent issue: #3737. Depends on #3739 (core tool integrity, merged).
This Draft has been refreshed after #3739 merged and now includes merge commit
2ae4cae26729b75abc36d5428c9e3a4b8b81a797with the currentmain. Its diff relative to currentmaincontains only the native replay changes. The native-only incremental comparison remains available here. EN/ZH context documentation is included.Evidence
Tests cover SDK-shaped streaming/nonstream responses through real ReAct accumulation, handler execution, and the next Anthropic request. Two thinking blocks retain their own signatures and positions; complete and incomplete tool starts in the same truncated response are handled separately. Formatter tests verify one assistant tool batch and one user result batch.
Dependency-plus-native replay validation passes: 126 tests, 0 failures/errors, 1 existing skip; Spotless passed. After resolving the conflict against current
main,mvn -B -T1 -DforkCount=1 clean verifypasses: 11,377 tests, 0 failures, 0 errors, 242 skipped, across 75 Maven test-module summaries. The serial flags avoid the Windows fork-start resource failure seen with the default parallel run; they do not change production code.ZCode
anthropic-reasoning-metadata.tspreserves per-block provider metadata andreasoning-history-normalization.tschecks signature compatibility. DeepSeek Harnessreplay.tsaligns replay metadata to content-block indices. SDK event fixtures and local integration tests support ASJ's specific index/completion implementation.Merge Danger
Door: reversible code change. Blast radius: Anthropic request projection and indexed response history; providers without native indices retain the existing aggregation path. Signed thinking uses native replay; foreign thinking without an Anthropic signature retains the existing text fallback. No persistent schema migration. Review together with the core integrity contract, while keeping both diffs separate.
Checklist
Code formatting verified with Spotless.
Relevant tests pass on this PR's isolated source snapshot and declared dependency.
Javadoc comments follow project conventions.
Related EN/ZH documentation updated.
Code is ready for review.