ToolValidator
public final class ToolValidator
源码Source
io/agentscope/core/tool/ToolValidator.java:47–266工具校验器,让智能体以受控方式调用外部能力。位于 io.agentscope.core.tool 包。核心成员包括 validateInput、validateToolResultMatch。
Unified validator for tool-related operations.
This class provides validation capabilities for:
-
Schema validation - Validates tool input parameters against JSON Schema using networknt-schema
-
HITL validation - Validates ToolResult messages match pending ToolUse blocks
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static String validateInput(String input, Map<String, Object> schema)static | 校验输入。 Validate tool input parameters against a JSON Schema using networknt-schema. |
public static void validateToolResultMatch(Msg assistantMsg, List<Msg> inputMsgs)static | 校验 `validateToolResultMatch`。 Validate that ToolResult messages match pending ToolUse blocks. |
方法详情Method Detail
validateInput
public static String validateInput(String input, Map<String, Object> schema)
static
校验输入。
Validate tool input parameters against a JSON Schema using networknt-schema.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
input | String | 输入参数到校验。The input parameters to validate |
schema | Map<String, Object> | 模式定义(类型 `Map`)。The JSON Schema to validate against (from tool.getParameters()) |
String返回字符串结果。null if validation passes, or an error message describing the validation failures
源码Source
io/agentscope/core/tool/ToolValidator.java:77–106validateToolResultMatch
public static void validateToolResultMatch(Msg assistantMsg, List<Msg> inputMsgs)
static
校验 validateToolResultMatch。
Validate that ToolResult messages match pending ToolUse blocks.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
assistantMsg | Msg | assistant 消息(类型 `Msg`)。The assistant message that may contain pending ToolUse blocks |
inputMsgs | List<Msg> | 输入 Msgs(类型 `List`)。The input messages that should contain ToolResult blocks |
IllegalStateException可能抛出 `IllegalStateException`。if validation fails
源码Source
io/agentscope/core/tool/ToolValidator.java:229–265