Repository navigation
feature(tool): pregressive tool call events - #3712
Merged
jujn merged 6 commits intoOct 22, 2026
Merged
Conversation
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
jujn
approved these changes
Oct 22, 2026
…error fallback The batch-level onErrorResume in executeToolCalls re-processes every tool call after an infrastructure failure (e.g. SessionLogException): calls that already resolved through the executor's doOnNext received a second round of delta/end events, and their real result was replaced by a synthetic error in the returned list, so the event stream and the model-visible message disagreed (events said SUCCESS, message said error). Track resolved results per call id inside ReActAgent's per-batch ToolResultCallback (created fresh per batch, so the shared Toolkit stays stateless): onResult records the first resolution and skips later ones, and the fallback backfills real results for resolved calls instead of synthesizing errors. Recording before the suspended check also keeps tools that suspended earlier alive as suspended instead of demoting them to errors, so the HITL flow survives the batch error. The structured-output missing-result fallback now fires onResult as well so no End event arrives orphaned.
onStart was declared on the new ToolExecutionCallback interface but never invoked by the executor — the only caller was ReActAgent looping over approved calls at batch admission. ToolResultStartEvent therefore meant "batch admitted" rather than "this tool is running": in sequential batches a late tool's Start event preceded its actual execution by the full duration of the preceding tools, so End(t2) - Start(t0) still mixed in queue wait and per-tool latency remained unmeasurable (agentscope-ai#3223's original motivation, only half-fixed by progressive results). Fire onStart from a doOnSubscribe on the outermost per-tool mono in ToolExecutor.executeAll (outside the retry wrapper, so one logical invocation emits it exactly once), remove the admission loop in ReActAgent, and add the same hook to the structured-output path, which bypasses executeAll. onStart is idempotent in the callback, and the batch error fallback fires it defensively for queued calls that never reached the executor, so no End event arrives orphaned. Parallel mode (the default) is unaffected in practice: mergeSequential subscribes to every tool eagerly, so the executor-fired Start lands at essentially the same moment as before. Queue previews should read ToolCallStartEvent, which fires even earlier while the model streams the tool_use blocks. Docs restored to the honest "tool starts executing" semantics in both languages. Release notes are left to the release process.
kyy-logs
added a commit
to kyy-logs/agentscope-java
that referenced
this pull request
Oct 26, 2026
The merge of main into this branch dropped `import java.util.function.BiConsumer;` from ReActAgent. agentscope-ai#3712 removed the last upstream usages of the type and the import with them, while the permission helpers added here still use it, so both builds failed to compile at ReActAgent.java:842 and 855.
5 tasks done
chickenlj
added a commit
that referenced
this pull request
Nov 30, 2026
) (#4430) Fixes #4429 Backports #3712 (`db0b67eb8`, addressing #3223) from `main` to `2.0.x` as a fix release, with `2.0.x` compatibility adaptations and an `AsyncToolMiddleware` regression fix. Co-authored-by: Chickenlj <[email protected]>
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.
Background
Addresses #3223
Previously,
ReActAgentemitted tool result events only after the entire batch completed. A fast tool's result stayed invisible while a slower tool was running, delaying updates in SSE clients and UIs. Event timestamps were generated after batch completion; they were not necessarily identical.This change lets consumers receive each completed tool's result immediately while preserving the batch boundary for conversation updates and subsequent reasoning.
Why this approach
This implementation uses a callback to deliver results earlier while keeping the existing batch aggregation and consumption flow.
The proposed
FluxAPIs are feasible, but sharing their implementation with the oldMono<List<...>>API would require refactoring the existing execution flow. Restoring the final list order would not alone prove compatibility: concurrency limits, serial isolation, subscription timing, errors, retries, timeouts, and cancellation would also need regression testing. Keeping the old implementation separate would avoid that refactor but leave two execution paths to maintain.The callback runs before the existing
mergeSequential/collectListaggregation. This preserves the ordered batch result used by the agent and limits the scope of regression testing.Progressive events are enabled by default, without a flag. Events may arrive in completion order; consumers should match them by
toolCallId.PostActing, context updates, and the next model call still wait for the whole batch.Changes
ToolExecutionCallbackwith optionalonStart,onProgress, andonResultnotifications, plusToolkit.callToolsWithCallback(...). Preserve existing chunk callback signatures through an adapter.ToolExecutorbefore ordered aggregation, after existing retry, timeout, and tool error handling.ReActAgent. Preserve existing batch Start timing and skip result Delta/End events for suspended results.generate_responseresults in callback publication without duplicating ordinary tool events. Native structured output continues to bypass tool dispatch; provider results and permission denials retain their existing event conversion.