类 ToolUseBlock

java.lang.Object
io.agentscope.core.message.ContentBlock
io.agentscope.core.message.ToolUseBlock
所有已实现的接口:
State

public final class ToolUseBlock extends ContentBlock
Represents a tool use request within a message.

This content block is used when an agent requests to execute a tool. It contains the tool's unique identifier, name, input parameters, and optionally the raw content for streaming tool calls.

The tool input is stored as a generic map of string keys to object values, allowing for flexible parameter passing to different tool implementations.

  • 字段详细资料

    • METADATA_THOUGHT_SIGNATURE

      public static final String METADATA_THOUGHT_SIGNATURE
      Metadata key for Gemini thought signature (byte[] value).
      另请参阅:
  • 构造器详细资料

    • ToolUseBlock

      public ToolUseBlock(String id, String name, Map<String,Object> input, Map<String,Object> metadata)
      Creates a new tool use block for JSON deserialization.
      参数:
      id - Unique identifier for this tool call
      name - Name of the tool to execute
      input - Input parameters for the tool (will be defensively copied)
      metadata - Provider-specific metadata (will be defensively copied)
    • ToolUseBlock

      public ToolUseBlock(String id, String name, Map<String,Object> input)
      Creates a new tool use block without metadata (convenience constructor).
      参数:
      id - Unique identifier for this tool call
      name - Name of the tool to execute
      input - Input parameters for the tool (will be defensively copied)
    • ToolUseBlock

      public ToolUseBlock(String id, String name, Map<String,Object> input, String content, Map<String,Object> metadata)
      Creates a new tool use block with raw content for streaming.
      参数:
      id - Unique identifier for this tool call
      name - Name of the tool to execute
      input - Input parameters for the tool (will be defensively copied)
      content - Raw content for streaming tool calls
      metadata - Provider-specific metadata (will be defensively copied)
  • 方法详细资料

    • getId

      public String getId()
      Gets the unique identifier of this tool call.
      返回:
      The tool call ID
    • getName

      public String getName()
      Gets the name of the tool to execute.
      返回:
      The tool name
    • getInput

      public Map<String,Object> getInput()
      Gets the input parameters for the tool.
      返回:
      The tool input parameters map
    • getContent

      public String getContent()
      Gets the raw content for streaming tool calls.
      返回:
      The raw content, or null if not set
    • getMetadata

      public Map<String,Object> getMetadata()
      Gets the provider-specific metadata.

      For Gemini, this may contain the thought signature under the key METADATA_THOUGHT_SIGNATURE.

      返回:
      The metadata map, or an empty map if not set
    • builder

      public static ToolUseBlock.Builder builder()
      Creates a new builder for constructing a ToolUseBlock.
      返回:
      A new builder instance