From b9912620be84e043f58ecafe3ebb0ebd97925b65 Mon Sep 17 00:00:00 2001 From: sparkle6979 Date: Sun, 17 May 2026 16:24:31 +0800 Subject: [PATCH 1/2] fix(tool): preserve tool id and name in timeout error results When a tool call times out in executeWithInfrastructure(), the error path via onErrorResume creates a ToolResultBlock.error() without calling withIdAndName(). The normal path goes through .map() which sets id/name, but timeout errors bypass .map(). This causes PostActingEvent.getToolResult() to return a ToolResultBlock with null id and name, while getToolResultMsg() has the correct values (rebuilt from ToolUseBlock by ToolResultMessageBuilder). Fix by chaining .withIdAndName() in the onErrorResume handler. Fixes #1389 --- .../io/agentscope/core/tool/ToolExecutor.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java b/agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java index 5ba4af8f1b..db79e23761 100644 --- a/agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java +++ b/agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java @@ -22,6 +22,13 @@ import io.agentscope.core.shutdown.GracefulShutdownManager; import io.agentscope.core.tracing.TracerRegistry; import io.agentscope.core.util.ExceptionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.core.scheduler.Schedulers; +import reactor.util.retry.Retry; + import java.time.Duration; import java.util.HashMap; import java.util.List; @@ -29,12 +36,6 @@ import java.util.concurrent.ExecutorService; import java.util.function.BiConsumer; import java.util.function.Predicate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.core.scheduler.Schedulers; -import reactor.util.retry.Retry; /** * Unified executor for tool execution with infrastructure concerns. @@ -336,7 +337,8 @@ private Mono executeWithInfrastructure( logger.warn("Tool call failed: {}", toolCall.getName(), e); String errorMsg = ExceptionUtils.getErrorMessage(e); return Mono.just( - ToolResultBlock.error("Tool execution failed: " + errorMsg)); + ToolResultBlock.error("Tool execution failed: " + errorMsg) + .withIdAndName(toolCall.getId(), toolCall.getName())); }); } From cd6ec250254c18284a4db96e5d4c155a2dfa158c Mon Sep 17 00:00:00 2001 From: sparkle6979 Date: Sun, 17 May 2026 16:34:51 +0800 Subject: [PATCH 2/2] chore: apply spotless formatting --- .../java/io/agentscope/core/tool/ToolExecutor.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java b/agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java index db79e23761..1718561248 100644 --- a/agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java +++ b/agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java @@ -22,13 +22,6 @@ import io.agentscope.core.shutdown.GracefulShutdownManager; import io.agentscope.core.tracing.TracerRegistry; import io.agentscope.core.util.ExceptionUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.core.scheduler.Schedulers; -import reactor.util.retry.Retry; - import java.time.Duration; import java.util.HashMap; import java.util.List; @@ -36,6 +29,12 @@ import java.util.concurrent.ExecutorService; import java.util.function.BiConsumer; import java.util.function.Predicate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.core.scheduler.Schedulers; +import reactor.util.retry.Retry; /** * Unified executor for tool execution with infrastructure concerns.