类 ToolCallParam

java.lang.Object
io.agentscope.core.tool.ToolCallParam

public class ToolCallParam extends Object
Parameters for tool invocation.

This class encapsulates all the information needed to call a tool, including the tool use block (containing metadata like call ID and tool name), input parameters, and the calling agent.

Using a parameter object instead of multiple method parameters provides better extensibility - new parameters can be added without breaking existing code.

Example usage:


 ToolCallParam param = ToolCallParam.builder()
     .toolUseBlock(toolUseBlock)
     .input(Map.of("key", "value"))
     .agent(agent)
     .build();

 ToolResultBlock result = tool.callAsync(param).block();
 
  • 方法详细资料

    • getToolUseBlock

      public ToolUseBlock getToolUseBlock()
      Gets the tool use block containing call metadata.
      返回:
      The tool use block
    • getInput

      public Map<String,Object> getInput()
      Gets the input parameters for the tool call.
      返回:
      Unmodifiable map of input parameters
    • getAgent

      public Agent getAgent()
      Gets the agent making the call.
      返回:
      The agent, or null if not provided
    • getRuntimeContext

      public RuntimeContext getRuntimeContext()
      Gets the runtime context for this tool call.
      返回:
      The runtime context, or null if not provided
    • getContext

      @Deprecated public ToolExecutionContext getContext()
      已过时。
      Use getRuntimeContext() instead.
      Gets the tool execution context.
      返回:
      The execution context derived from RuntimeContext, or null
    • getEmitter

      public ToolEmitter getEmitter()
      Gets the ToolEmitter for streaming tool output.

      Tools can use this emitter to send intermediate progress updates during execution. If no emitter is configured, returns a no-op emitter that silently discards chunks.

      返回:
      The ToolEmitter, never null
    • builder

      public static ToolCallParam.Builder builder()
      Creates a new builder for constructing ToolCallParam instances.
      返回:
      A new builder
    • builder

      public static ToolCallParam.Builder builder(ToolCallParam source)
      Creates a new builder initialized with values from an existing ToolCallParam.

      This is useful for creating a modified copy of an existing parameter object. The builder copies all values from the source object, allowing selective modifications before building a new instance.

      Example usage:

      
       ToolCallParam original = ...;
       ToolCallParam modified = ToolCallParam.builder(original)
           .input(Map.of("newKey", "newValue"))
           .build();
       

      Note: The input map structure is copied so that entries can be modified independently, but nested values (typed as Object) remain shared. Immutable fields (toolUseBlock, agent, context, emitter) are shared by reference.

      参数:
      source - The existing ToolCallParam to copy values from
      返回:
      A new builder pre-populated with the source's values
      抛出:
      NullPointerException - if source is null