接口 ToolResultConverter
- 所有已知实现类:
DefaultToolResultConverter
public interface ToolResultConverter
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() { ... }
- 另请参阅:
-
方法概要
修饰符和类型方法说明Convert tool call result to ToolResultBlock.
-
方法详细资料
-
convert
Convert tool call result to ToolResultBlock.- 参数:
result- the tool call result (may be null)returnType- the return type of the tool method (may be null)- 返回:
- ToolResultBlock containing the converted result (never null)
-