ToolResultMessage
public final class ToolResultMessage extends Msg
io/agentscope/core/message/ToolResultMessage.java:37–220工具结果消息,在智能体、模型与前端之间传递结构化消息和事件。位于 io.agentscope.core.message 包,继承自 Msg。核心成员包括 builder、ToolResultMessage。
A Msg with MsgRole#TOOL pinned at construction time.
Carries one or more ToolResultBlocks as its content. The
three-argument constructor takes the tool call id, tool name and a result
string, automatically wrapping the string in a TextBlock inside the
ToolResultBlock.
Also offers an independent Builder that lets callers accumulate
multiple tool results, attach metadata, or set timestamp/usage explicitly.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | 构建器,用于构建并配置目标实例。 Fluent builder for `ToolResultMessage`. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public ToolResultMessage(String toolCallId, String toolName, String resultText) | 初始化 `ToolResultMessage` 实例。 Creates a new instance. |
public ToolResultMessage(ToolResultBlock... results) | 初始化 `ToolResultMessage` 实例。 Creates a new instance. |
public ToolResultMessage(List<ToolResultBlock> results) | 初始化 `ToolResultMessage` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static Builder builder()static | 返回构建器实例。 Creates a builder for `ToolResultMessage` with a randomly generated
ID and the current timestamp pre-populated. |
构造器详情Constructor Detail
ToolResultMessage
public ToolResultMessage(String toolCallId, String toolName, String resultText)
初始化 ToolResultMessage 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
toolCallId | String | 工具调用标识(类型 `String`)。The tool call id. |
toolName | String | 工具名称(类型 `String`)。The tool name. |
resultText | String | 结果文本(类型 `String`)。The result text. |
io/agentscope/core/message/ToolResultMessage.java:39–52ToolResultMessage
public ToolResultMessage(ToolResultBlock... results)
初始化 ToolResultMessage 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
results varargs | ToolResultBlock... | 结果(类型 `ToolResultBlock...`)。The results. |
io/agentscope/core/message/ToolResultMessage.java:54–63ToolResultMessage
public ToolResultMessage(List<ToolResultBlock> results)
初始化 ToolResultMessage 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
results | List<ToolResultBlock> | 结果(类型 `List`)。The results. |
io/agentscope/core/message/ToolResultMessage.java:65–74方法详情Method Detail
builder
public static Builder builder()
返回构建器实例。
Creates a builder for ToolResultMessage with a randomly generated ID and the current timestamp pre-populated.
Builderio/agentscope/core/message/ToolResultMessage.java:91–93嵌套类详情Nested Class Detail
Builder
public static final class Builder extends Msg.Builder构建器,用于构建并配置目标实例。位于 io.agentscope.core.message 包,继承自 Msg.Builder。核心成员包括 role、result、results、id、name、content。
Fluent builder for ToolResultMessage. The role is fixed to
MsgRole#TOOL and #role(MsgRole) is unsupported.
#result(String, String, String) and #result(ToolResultBlock)
append to the accumulating result list; #results(ToolResultBlock...)
and #results(List) (and the inherited content(...) setters)
replace it wholesale.
继承成员Inherited Members
MsgbuilderForRole, generateId, currentTimestamp, getId, getName, getRole, getContent, getMetadata, getTimestamp, getUsage, hasContentBlocks, getContentBlocks, getFirstContentBlock, getFirstContentBlock, hasStructuredData, getStructuredData, getStructuredData, getTextContent, getChatUsage, getGenerateReason, withGenerateReason, withContent, withMetadata, METADATA_GENERATE_REASON, METADATA_CONFIRM_RESULTS, METADATA_CONFIRM_REQUEST_REPLY_ID, METADATA_EXTERNAL_EXECUTION_REQUEST_REPLY_ID, METADATA_SYNTHETIC, METADATA_REMINDER_KIND