ToolCallsAccumulator
public class ToolCallsAccumulator implements ContentAccumulator<ToolUseBlock>
io/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:40–322工具调用 Accumulator,驱动智能体的推理、工具调用与会话执行。位于 io.agentscope.core.agent.accumulator 包,实现 ContentAccumulator<ToolUseBlock>。核心成员包括 add、hasContent、buildAggregated、buildAllToolCalls、getAccumulatedToolCall、getAllAccumulatedToolCalls。
Tool calls accumulator for accumulating streaming tool call chunks.
This accumulator supports multiple parallel tool calls and handles:
-
Tool name and ID accumulation
-
Incremental parameter merging
-
Raw JSON content accumulation and parsing
-
Placeholder name handling (e.g., "fragment")
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public void add(ToolUseBlock block) | 设置添加。 Performs the add operation. |
public boolean hasContent() | 判断是否具有内容。 Returns whether this has the content. |
public ContentBlock buildAggregated() | 构建 `buildAggregated`。 Builds the aggregated. |
public List<ToolUseBlock> buildAllToolCalls() | 构建所有工具调用。 Build all accumulated tool calls. |
public ToolUseBlock getAccumulatedToolCall(String id) | 获取 `getAccumulatedToolCall`。 Get accumulated tool call by ID. |
public List<ToolUseBlock> getAllAccumulatedToolCalls() | 获取 `getAllAccumulatedToolCalls`。 Get all accumulated tool calls. |
public String getCurrentToolCallId() | 获取当前工具调用标识。 Get the ID of the current (last) tool call being accumulated. |
public void reset() | 清空或重置内部状态。 Clears or resets internal state. |
方法详情Method Detail
add
public void add(ToolUseBlock block)
设置添加。
Performs the add operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
block | ToolUseBlock | 内容块(类型 `ToolUseBlock`)。The block. |
io/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:157–171hasContent
public boolean hasContent()
判断是否具有内容。
Returns whether this has the content.
booleanio/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:221–224buildAggregated
public ContentBlock buildAggregated()
构建 buildAggregated。
Builds the aggregated.
ContentBlockio/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:229–240buildAllToolCalls
public List<ToolUseBlock> buildAllToolCalls()
构建所有工具调用。
Build all accumulated tool calls.
List<ToolUseBlock>io/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:248–250getAccumulatedToolCall
public ToolUseBlock getAccumulatedToolCall(String id)
获取 getAccumulatedToolCall。
Get accumulated tool call by ID.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
id | String | 标识(类型 `String`)。The tool call ID to look up |
ToolUseBlockio/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:261–279getAllAccumulatedToolCalls
public List<ToolUseBlock> getAllAccumulatedToolCalls()
获取 getAllAccumulatedToolCalls。
Get all accumulated tool calls.
List<ToolUseBlock>io/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:288–290getCurrentToolCallId
public String getCurrentToolCallId()
获取当前工具调用标识。
Get the ID of the current (last) tool call being accumulated.
Stringio/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:300–311reset
public void reset()
清空或重置内部状态。
Clears or resets internal state.
io/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:316–321