AS AgentScopeAPI 手册 / API Reference

ToolCallParam

public class ToolCallParam
源码Source io/agentscope/core/tool/ToolCallParam.java:46–259

工具调用参数,让智能体以受控方式调用外部能力。位于 io.agentscope.core.tool 包。核心成员包括 getToolUseBlock、getInput、getAgent、getRuntimeContext、getContext、getEmitter。

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();
`

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Builder类class
ToolCallParam的构建器。
Builder for ToolCallParam.

方法摘要Method Summary

方法Method说明Description
public ToolUseBlock getToolUseBlock()
获取工具使用块。
Gets the tool use block containing call metadata.
public Map<String, Object> getInput()
获取输入参数用于工具调用。
Gets the input parameters for the tool call.
public Agent getAgent()
获取智能体。
Gets the agent making the call.
public RuntimeContext getRuntimeContext()
获取运行时上下文用于此工具调用。
Gets the runtime context for this tool call.
public ToolExecutionContext getContext()
deprecated
获取工具执行上下文。
Gets the tool execution context.
public ToolEmitter getEmitter()
获取ToolEmitter 用于流式工具输出。
Gets the ToolEmitter for streaming tool output.
public static Builder builder()
static
返回构建器实例。
Creates a new builder for constructing ToolCallParam instances.
public static Builder builder(ToolCallParam source)
static
返回构建器实例。
Creates a new builder initialized with values from an existing ToolCallParam.

方法详情Method Detail

getToolUseBlock

public ToolUseBlock getToolUseBlock()

获取工具使用块。

Gets the tool use block containing call metadata.

返回Returns ToolUseBlock
工具使用块。The tool use block
源码Source io/agentscope/core/tool/ToolCallParam.java:67–69

getInput

public Map<String, Object> getInput()

获取输入参数用于工具调用。

Gets the input parameters for the tool call.

返回Returns Map<String, Object>
返回映射。Unmodifiable map of input parameters
源码Source io/agentscope/core/tool/ToolCallParam.java:76–78

getAgent

public Agent getAgent()

获取智能体。

Gets the agent making the call.

返回Returns Agent
返回智能体。The agent, or null if not provided
源码Source io/agentscope/core/tool/ToolCallParam.java:85–87

getRuntimeContext

public RuntimeContext getRuntimeContext()

获取运行时上下文用于此工具调用。

Gets the runtime context for this tool call.

返回Returns RuntimeContext
返回RuntimeContext。The runtime context, or null if not provided
源码Source io/agentscope/core/tool/ToolCallParam.java:94–96

getContext

public ToolExecutionContext getContext()
deprecated

获取工具执行上下文。

Gets the tool execution context.

已弃用。Deprecated. 已弃用,请改用受支持的替代 API。Use `#getRuntimeContext()` instead.
返回Returns ToolExecutionContext
返回ToolExecutionContext。The execution context derived from RuntimeContext, or null
源码Source io/agentscope/core/tool/ToolCallParam.java:104–107

getEmitter

public ToolEmitter getEmitter()

获取ToolEmitter 用于流式工具输出。

Gets the ToolEmitter for streaming tool output.

返回Returns ToolEmitter
返回ToolEmitter。The ToolEmitter, never null
源码Source io/agentscope/core/tool/ToolCallParam.java:117–119

builder

public static Builder builder()
static

返回构建器实例。

Creates a new builder for constructing ToolCallParam instances.

返回Returns Builder
一种新的构建器。A new builder
源码Source io/agentscope/core/tool/ToolCallParam.java:126–128

builder

public static Builder builder(ToolCallParam source)
static

返回构建器实例。

Creates a new builder initialized with values from an existing ToolCallParam.

参数Parameters
名称Name类型Type说明Description
sourceToolCallParam来源(类型 `ToolCallParam`)。The existing ToolCallParam to copy values from
返回Returns Builder
返回当前实例,以支持链式调用。A new builder pre-populated with the source's values
抛出Throws
  • NullPointerException 可能抛出 `NullPointerException`。if source is null
源码Source io/agentscope/core/tool/ToolCallParam.java:153–156

嵌套类详情Nested Class Detail

Builder

public static class Builder

ToolCallParam的构建器。位于 io.agentscope.core.tool 包。核心成员包括 toolUseBlock、input、agent、runtimeContext、context、emitter。

Builder for ToolCallParam.

基于官方固定版本源码静态生成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.