AS AgentScopeAPI 手册 / API Reference

ToolResultConverter

public interface ToolResultConverter
源码Source io/agentscope/core/tool/ToolResultConverter.java:48–58

定义工具结果转换器契约的接口。位于 io.agentscope.core.tool 包。核心成员包括 convert。

Converts tool method return values to ToolResultBlock. Custom implementations can override conversion logic for specific tools.

This interface allows users to customize how tool results are converted and presented to LLMs. Implementations can control JSON serialization, add metadata, filter sensitive data, or compress large outputs.

Usage Example:

`public class CustomConverter implements ToolResultConverter {
@Override
public ToolResultBlock convert(Object result, Type returnType) {
// Custom conversion logic
return ToolResultBlock.of(...);
}
}

@Tool(
name = "my_tool",
converter = CustomConverter.class
)
public String myTool() { ... }
`

方法摘要Method Summary

方法Method说明Description
public ToolResultBlock convert(Object result, Type returnType)
转换工具调用结果到 ToolResultBlock。
Convert tool call result to ToolResultBlock.

方法详情Method Detail

convert

public ToolResultBlock convert(Object result, Type returnType)

转换工具调用结果到 ToolResultBlock。

Convert tool call result to ToolResultBlock.

参数Parameters
名称Name类型Type说明Description
resultObject结果(类型 `Object`)。the tool call result (may be null)
returnTypeTypereturn 类型(类型 `Type`)。the return type of the tool method (may be null)
返回Returns ToolResultBlock
返回ToolResultBlock。ToolResultBlock containing the converted result (never null)
源码Source io/agentscope/core/tool/ToolResultConverter.java:57
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.