Repository navigation
Description
AgentScope-Java is an open-source project. To involve a broader community, we recommend asking your questions in English.
Is your feature request related to a problem? Please describe.
When an LLM returns multiple tool_use blocks in a single reasoning response, AgentScope collects all tool results before emitting any ToolResultEndEvents. This means:
- All
ToolResultEndEvents share the samecreatedAttimestamp — the moment the last tool finishes — so per-tool duration is indistinguishable. - Downstream consumers (SSE, event pipeline, UI) see all results arrive simultaneously even if some tools completed much earlier.
- Per-tool latency cannot be measured from the event stream, making it impossible to display "Tool A took 50ms, Tool B took 300ms" in a dashboard.
The root cause is that ToolExecutor.executeAll() uses Flux.concat(chunks).collectList() (returning Mono<List<ToolResultBlock>>), and ReActAgent.runToolBatch() subscribes to this Mono, emitting all ToolResultEndEvents in a single batch callback after every tool has finished.
Describe the solution you'd like
Add a progressiveToolResults option to ToolkitConfig (default false for backward compatibility). When enabled:
-
ToolExecutorgains anexecuteAllProgressive()method that returnsFlux<ToolResultBlock>instead ofMono<List<ToolResultBlock>>— same concurrency-partitioning logic (concurrency-safe tools run in parallel viamergeSequential, unsafe tools get serial slots), just withoutcollectList(). -
Toolkitgains acallToolsProgressive()method delegating toexecuteAllProgressive(). -
ReActAgentgains anexecuteToolCallsProgressive()method returningFlux<Map.Entry<ToolUseBlock, ToolResultBlock>>, with per-tool id matching. InrunToolBatch(), a newif (progressive)branch emits eachToolResultEndEventviasubscribe(onNext, onError, onComplete)instead of waiting for the batch. Structured-output calls fall back to the batch path. -
PostActingEvent timing is unchanged — hooks still fire after all tools complete (via
resultHolder), so existing hook aggregation logic is not affected. -
Error handling is per-tool —
executeWithInfrastructurealready wraps each tool inonErrorResume -> ToolResultBlock.error(...), so a single tool's failure produces an error result without terminating the stream.
Usage:
Toolkit toolkit = new Toolkit(
ToolkitConfig.builder()
.progressiveToolResults(true)
.build()
);
ReActAgent agent = ReActAgent.builder()
.model(model)
.toolkit(toolkit)
.build();Before (all results delivered together):
T0: TOOL_CALL_START(A) TOOL_CALL_START(B) TOOL_CALL_START(C)
T1: TOOL_RESULT_END(A) TOOL_RESULT_END(B) TOOL_RESULT_END(C) <- same timestamp
-> durationMs: A = B = C = T1 - T0
After (each result delivered on completion):
T0: TOOL_CALL_START(A) TOOL_CALL_START(B) TOOL_CALL_START(C)
T1: TOOL_RESULT_END(A) <- A completed first
T2: TOOL_RESULT_END(B) <- B completed
T3: TOOL_RESULT_END(C) <- C completed
-> durationMs: A = T1-T0, B = T2-T0, C = T3-T0 <- distinct
Describe alternatives you've considered
-
Metadata-only approach (no execution model change): Record each tool's real completion time in
ToolResultBlock.metadataviaexecuteWithInfrastructure, then read it back when constructingToolResultEndEvent. This requires zero architectural changes but events are still batch-delivered — only the timestamp is accurate, not the delivery timing. UI consumers that rely on event arrival order cannot display progressive results. -
Change
executeAllreturn type toFluxunconditionally: Breaking change — every caller ofcallTools/executeAllwould need updating, including middleware, external executors, and user code. -
PostActingEvent also progressive: Considered firing hooks per-tool on completion. Rejected because some hooks aggregate across tool results (e.g., conflict detection) and would break if fired before all results are available.
-
Naming:
streamingToolResults: Initially considered but rejected becausestreamingin AgentScope is already associated with model-level streaming responses (streamEvents,StreamableAgent), which would cause naming confusion.progressivemore accurately describes the per-tool progressive delivery semantics.
Additional context
When multiple tools are executed in a batch, tool results are not returned until all tools have finished executing. This causes a usability issue: the user's conversation appears to be hanging while waiting for tool results, even though some tools have already completed. Due to this framework limitation, completed results cannot be exposed to the user early. Exposing partial results as they become available would let users see real-time execution progress, significantly improving the user experience.
cur verison agentScope 2.0.2-subagent-bugfix
Activity
rudy2steiner commentedon Sep 21, 2026
i'll work on it
songdayi commentedon Sep 21, 2026
@rudy2steiner 标题写错了
更正为 [Feature]: Deliver each tool result progressively as it completes during batch execution (progressiveToolResults)
然后描述内容我也重新修订了
[-][Feature]: Stream tool results individually as each tool completes (streamingToolResults)[/-][+][Feature]: Deliver each tool result progressively as it completes during batch execution (progressiveToolResults)[/+]oss-maintainer commentedon Sep 21, 2026
Issue Evaluation
Category:
enhancement| Status: Evaluated — design questions remain (verified againstmain@8ca0080)Claims verified. The diagnosis is accurate on the current code:
ToolExecutor.executeAll()returnsMono<List<ToolResultBlock>>and collects the concatenated chunks before anything is published —agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java:305-355.ReActAgentsubscribes once to that completed list and only then emits theToolResultEndEvents —agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java:3166-3261.ToolResultBlock.error(...)—agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java:397-406, so a per-tool error path in a progressive stream does not need new error plumbing.PostActingprocessing —agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java:2832-2857,:2880-2946.One correction:
createdAtis not shared. Each event constructs its ownInstant.now()—agentscope-core/src/main/java/io/agentscope/core/event/AgentEvent.java:105-113,agentscope-core/src/main/java/io/agentscope/core/event/ToolResultEndEvent.java:60-66. The timestamps are near-simultaneous and post-batch, not literally identical, so "all results share the samecreatedAt" overstates it. The underlying problem (delivery timing, not duration measurement) is real.Design points worth settling before code:
mergeSequential, which preserves source order rather than completion order —agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java:332-355. A progressive stream that emits on completion changes observable ordering for downstream consumers; that trade-off should be explicit in the flag's contract, not just in the implementation.ToolUseBlockandToolResultBlockpositionally —agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java:3465-3476. Completion-order delivery needs id-based pairing throughout, which is a wider change than adding aFluxvariant.ReActAgent.java:1245-1277) and the fallback synthetic path bypassesToolExecutor(ReActAgent.java:3511-3597). The proposal's "structured-output falls back to batch" needs a precise statement of which events a progressive consumer should expect in that mode.ReActAgent.java:695-699,:3115-3164. A per-subscription progressive emitter must not reuse that mutable state.Feasibility: feasible with a default-off
ToolkitConfigflag plus additiveFlux-returning methods — the existingMono<List<...>>API and default behaviour can be preserved (ToolkitConfig.java:119-143,Toolkit.java:511-525). Non-breaking for users who do not opt in; opted-in consumers must tolerate completion-order arrival.Priority: medium — observable per-tool latency is a real gap for SSE/UI consumers, but there is no correctness or data-loss impact.
@rudy2steiner you are assigned and have picked this up, so no bot-generated patch here — please take the four points above into the design (ordering + id-based pairing are the ones that can silently break consumers).
Automated evaluation by github-manager-bot
fix(core): fire onStart when a tool actually begins executing
feature(tool): pregressive tool call events (#3712)
xzxiaoshan commentedon Oct 23, 2026
complated as #3712
fix(core,harness): backport progressive tool call events to 2.0.x (#4429