DefaultToolResultConverter
public class DefaultToolResultConverter implements ToolResultConverter
源码Source
io/agentscope/core/tool/DefaultToolResultConverter.java:39–97默认工具结果转换器,让智能体以受控方式调用外部能力。位于 io.agentscope.core.tool 包,实现 ToolResultConverter。核心成员包括 convert、handleNull、handleVoid、serialize。
Default implementation of ToolResultConverter. Handles JSON serialization with schema information.
This converter:
-
Converts null results to "null" text
-
Converts void results to "Done" text
-
Passes through ToolResultBlock instances unchanged
-
Serializes objects to JSON with schema information
-
Falls back to toString() if serialization fails
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public ToolResultBlock convert(Object result, Type returnType) | 执行转换相关操作。 Performs the convert operation. |
protected ToolResultBlock handleNull() | 处理 `handleNull`。 Handle null result. |
protected ToolResultBlock handleVoid() | 处理 `handleVoid`。 Handle void return type. |
protected ToolResultBlock serialize(Object result, Type returnType) | 执行 `serialize` 方法。 Serialize result to JSON string with schema. |
方法详情Method Detail
convert
public ToolResultBlock convert(Object result, Type returnType)
执行转换相关操作。
Performs the convert operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
result | Object | 结果(类型 `Object`)。The result. |
returnType | Type | return 类型(类型 `Type`)。The return type. |
ToolResultBlock返回ToolResultBlock。Returns tool result block.
源码Source
io/agentscope/core/tool/DefaultToolResultConverter.java:43–59handleNull
protected ToolResultBlock handleNull()
处理 handleNull。
Handle null result.
ToolResultBlock返回ToolResultBlock。ToolResultBlock with "null" text
源码Source
io/agentscope/core/tool/DefaultToolResultConverter.java:66–68handleVoid
protected ToolResultBlock handleVoid()
处理 handleVoid。
Handle void return type.
ToolResultBlock返回ToolResultBlock。ToolResultBlock with "Done" text
源码Source
io/agentscope/core/tool/DefaultToolResultConverter.java:75–77serialize
protected ToolResultBlock serialize(Object result, Type returnType)
执行 serialize 方法。
Serialize result to JSON string with schema.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
result | Object | 结果(类型 `Object`)。the result to serialize |
returnType | Type | return 类型(类型 `Type`)。the return type |
ToolResultBlock返回ToolResultBlock。ToolResultBlock with JSON string and schema
源码Source
io/agentscope/core/tool/DefaultToolResultConverter.java:86–96