AS AgentScopeAPI 手册 / API Reference

ToolCallsAccumulator

public class ToolCallsAccumulator implements ContentAccumulator<ToolUseBlock>
源码Source 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.

参数Parameters
名称Name类型Type说明Description
blockToolUseBlock内容块(类型 `ToolUseBlock`)。The block.
源码Source io/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:157–171

hasContent

public boolean hasContent()

判断是否具有内容。

Returns whether this has the content.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:221–224

buildAggregated

public ContentBlock buildAggregated()

构建 buildAggregated。

Builds the aggregated.

返回Returns ContentBlock
返回ContentBlock。Returns content block.
源码Source io/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:229–240

buildAllToolCalls

public List<ToolUseBlock> buildAllToolCalls()

构建所有工具调用。

Build all accumulated tool calls.

返回Returns List<ToolUseBlock>
工具调用的列出。List of tool calls
源码Source io/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:248–250

getAccumulatedToolCall

public ToolUseBlock getAccumulatedToolCall(String id)

获取 getAccumulatedToolCall。

Get accumulated tool call by ID.

参数Parameters
名称Name类型Type说明Description
idString标识(类型 `String`)。The tool call ID to look up
返回Returns ToolUseBlock
返回ToolUseBlock。The accumulated ToolUseBlock, or null if not found
源码Source io/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:261–279

getAllAccumulatedToolCalls

public List<ToolUseBlock> getAllAccumulatedToolCalls()

获取 getAllAccumulatedToolCalls。

Get all accumulated tool calls.

返回Returns List<ToolUseBlock>
返回列出。List of all accumulated ToolUseBlocks
源码Source io/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:288–290

getCurrentToolCallId

public String getCurrentToolCallId()

获取当前工具调用标识。

Get the ID of the current (last) tool call being accumulated.

返回Returns String
返回字符串结果。The current tool call ID, or null if no tool call is being accumulated
源码Source io/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:300–311

reset

public void reset()

清空或重置内部状态。

Clears or resets internal state.

源码Source io/agentscope/core/agent/accumulator/ToolCallsAccumulator.java:316–321
基于官方固定版本源码静态生成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.