Skip to content

Commit a17033a

Browse files
authored
fix(tool): preserve tool id and name in timeout error results (#1431)
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 correctly 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: chain `.withIdAndName(toolCall.getId(), toolCall.getName())` in the `onErrorResume` handler. Fixes #1389
1 parent a80e090 commit a17033a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ private Mono<ToolResultBlock> executeWithInfrastructure(
336336
logger.warn("Tool call failed: {}", toolCall.getName(), e);
337337
String errorMsg = ExceptionUtils.getErrorMessage(e);
338338
return Mono.just(
339-
ToolResultBlock.error("Tool execution failed: " + errorMsg));
339+
ToolResultBlock.error("Tool execution failed: " + errorMsg)
340+
.withIdAndName(toolCall.getId(), toolCall.getName()));
340341
});
341342
}
342343

0 commit comments

Comments
 (0)