AS AgentScopeAPI 手册 / API Reference

MessageConvertUtil

public class MessageConvertUtil
源码Source io/agentscope/core/a2a/server/utils/MessageConvertUtil.java:44–326

消息转换 Util,支持智能体之间的发现、委派与协作。位于 io.agentscope.core.a2a.server.utils 包。核心成员包括 convertFromMsgToMessage、compactStreamingChunks、convertFromContentBlocks、convertFromMessageToMsgs。

Message Converter between Agentscope Msg and A2A Message or Artifact.

方法摘要Method Summary

方法Method说明Description
public static Message convertFromMsgToMessage(List<Msg> msgs, String taskId, String contextId)
static
转换列出的`Msg`到`Message`。
Convert a list of `Msg` to `Message`.
public static List<Msg> compactStreamingChunks(List<Msg> msgs)
static
设置该参数。
Compact consecutive streaming delta messages that share the same message id.
public static Message convertFromMsgToMessage(Msg msg, String taskId, String contextId)
static
转换`Msg`到`Message`。
Convert a `Msg` to `Message`.
public static List<Part<?>> convertFromContentBlocks(Msg msg)
static
转换 `convertFromContentBlocks`。
Convert content blocks in `Msg` to list of `Part`.
public static List<Part<?>> convertFromContentBlocks(Msg msg, boolean streamingChunk)
static
转换 `convertFromContentBlocks`。
Convert content blocks in `Msg` to list of `Part`.
public static List<Msg> convertFromMessageToMsgs(Message message)
static
转换A2A`Message`到列出的`Msg`。
Convert a A2A `Message` to List of `Msg`.

方法详情Method Detail

convertFromMsgToMessage

public static Message convertFromMsgToMessage(List<Msg> msgs, String taskId, String contextId)
static

转换列出的Msg到Message。

Convert a list of Msg to Message.

参数Parameters
名称Name类型Type说明Description
msgsList<Msg>消息到转换的列出。the list of Msg to convert
taskIdString任务标识(类型 `String`)。the taskId
contextIdString上下文标识(类型 `String`)。the contextId
返回Returns Message
已转换消息对象。the converted Message object
源码Source io/agentscope/core/a2a/server/utils/MessageConvertUtil.java:59–62

compactStreamingChunks

public static List<Msg> compactStreamingChunks(List<Msg> msgs)
static

设置该参数。

Compact consecutive streaming delta messages that share the same message id.

参数Parameters
名称Name类型Type说明Description
msgsList<Msg>消息列表(类型 `List`)。messages emitted by the streaming event pipeline
返回Returns List<Msg>
返回列出。messages with consecutive text/thinking deltas merged per message id
源码Source io/agentscope/core/a2a/server/utils/MessageConvertUtil.java:74–98

convertFromMsgToMessage

public static Message convertFromMsgToMessage(Msg msg, String taskId, String contextId)
static

转换Msg到Message。

Convert a Msg to Message.

参数Parameters
名称Name类型Type说明Description
msgMsg消息到转换。the Msg to convert
taskIdString任务标识(类型 `String`)。the taskId
contextIdString上下文标识(类型 `String`)。the contextId
返回Returns Message
已转换消息对象。the converted Message object
源码Source io/agentscope/core/a2a/server/utils/MessageConvertUtil.java:108–120

convertFromContentBlocks

public static List<Part<?>> convertFromContentBlocks(Msg msg)
static

转换 convertFromContentBlocks。

Convert content blocks in Msg to list of Part.

参数Parameters
名称Name类型Type说明Description
msgMsg消息(类型 `Msg`)。the Msg saved content blocks to convert
返回Returns List<Part<?>>
片段的列出。list of Part
源码Source io/agentscope/core/a2a/server/utils/MessageConvertUtil.java:128–130

convertFromContentBlocks

public static List<Part<?>> convertFromContentBlocks(Msg msg, boolean streamingChunk)
static

转换 convertFromContentBlocks。

Convert content blocks in Msg to list of Part.

参数Parameters
名称Name类型Type说明Description
msgMsg消息(类型 `Msg`)。the Msg saved content blocks to convert
streamingChunkboolean流式分块(类型 `boolean`)。whether these parts represent streaming delta chunks
返回Returns List<Part<?>>
片段的列出。list of Part
源码Source io/agentscope/core/a2a/server/utils/MessageConvertUtil.java:139–160

convertFromMessageToMsgs

public static List<Msg> convertFromMessageToMsgs(Message message)
static

转换A2AMessage到列出的Msg。

Convert a A2A Message to List of Msg.

参数Parameters
名称Name类型Type说明Description
messageMessage消息(类型 `Message`)。a2a protocol message from a2a client.
返回Returns List<Msg>
`Msg`的列出。list of `Msg`
源码Source io/agentscope/core/a2a/server/utils/MessageConvertUtil.java:229–270
基于官方固定版本源码静态生成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.