Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.agentscope.core.shutdown.GracefulShutdownManager;
import io.agentscope.core.tracing.TracerRegistry;
import io.agentscope.core.util.ExceptionUtils;
import io.agentscope.core.util.JsonUtils;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -208,7 +209,8 @@ private Mono<ToolResultBlock> executeCore(ToolCallParam param) {

// Validate input against schema
String validationError =
ToolValidator.validateInput(toolCall.getContent(), tool.getParameters());
ToolValidator.validateInput(
JsonUtils.resolveToolCallArgsJson(toolCall), tool.getParameters());
if (validationError != null) {
String errorMsg =
String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ void shouldExecuteToolsInParallel() {
"\"HelloWorld\"", extractFirstText(concatResponse), "Concat tool result mismatch");
}

@Test
@DisplayName("Should validate parsed input when raw content is absent")
void shouldValidateInputWhenRawContentIsAbsent() {
Map<String, Object> input = Map.of("a", 10, "b", 20);
ToolUseBlock toolCall =
ToolUseBlock.builder().id("call-input-only").name("add").input(input).build();

ToolResultBlock result =
toolkit.callTool(ToolCallParam.builder().toolUseBlock(toolCall).build())
.block(TIMEOUT);

assertNotNull(result, "Result should not be null");
assertEquals("30", extractFirstText(result));
}

@Test
@DisplayName("Should wrap tool errors inside executor response")
void shouldReturnErrorWhenToolThrows() {
Expand Down
Loading