Class ResponseConverter
java.lang.Object
com.google.adk.a2a.converters.ResponseConverter
Utility for converting ADK events to A2A spec messages (and back).
**EXPERIMENTAL:** Subject to change, rename, or removal in any future patch release. Do not use in production code.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordSimple REST-friendly wrapper to carry either a message result or a task result. -
Method Summary
Modifier and TypeMethodDescriptionclientEventToEvent(io.a2a.client.ClientEvent event, InvocationContext invocationContext) Converts a A2AClientEventto an ADKEvent, based on the event type.static io.a2a.spec.MessageeventsToMessage(List<Event> events, String contextId, String taskId) Converts a list of ADK events into a single aggregated A2A message.static io.a2a.spec.MessageeventToMessage(Event event, String contextId) Converts a single ADK event into an A2A message.static EventmessageToEvent(io.a2a.spec.Message message, InvocationContext invocationContext) Converts an A2A message back to ADK events.static EventmessageToEvent(io.a2a.spec.Message message, InvocationContext invocationContext, boolean isPending) Converts an A2A message back to ADK events.messageToEvents(io.a2a.spec.Message message, String invocationId, String branch) Converts an A2A message back to ADK events.static EventmessageToFailedEvent(io.a2a.spec.Message message, InvocationContext invocationContext) Converts an A2A message for a failed task to ADK event filling in the error message.sendMessageResponseToEvents(io.a2a.spec.SendMessageResponse response, String invocationId, String branch) Converts aSendMessageResponsecontaining aMessageresult into ADK events.static EventtaskToEvent(io.a2a.spec.Task task, InvocationContext invocationContext) Converts an A2ATaskto an ADKEvent.
-
Method Details
-
sendMessageResponseToEvents
-
messageToEvents
-
eventsToMessage
-
eventToMessage
-
clientEventToEvent
public static Optional<Event> clientEventToEvent(io.a2a.client.ClientEvent event, InvocationContext invocationContext) Converts a A2AClientEventto an ADKEvent, based on the event type. Returns an empty optional if the event should be ignored (e.g. if the event is not a final update for TaskArtifactUpdateEvent or if the message is empty for TaskStatusUpdateEvent).- Throws:
IllegalArgumentException- if the event type is not supported.
-
messageToEvent
public static Event messageToEvent(io.a2a.spec.Message message, InvocationContext invocationContext) Converts an A2A message back to ADK events. -
messageToFailedEvent
public static Event messageToFailedEvent(io.a2a.spec.Message message, InvocationContext invocationContext) Converts an A2A message for a failed task to ADK event filling in the error message. -
messageToEvent
public static Event messageToEvent(io.a2a.spec.Message message, InvocationContext invocationContext, boolean isPending) Converts an A2A message back to ADK events. For streaming task in pending state it sets the thought field to true, to mark them as thought updates. -
taskToEvent
Converts an A2ATaskto an ADKEvent. If the artifacts are present, the last artifact is used. If not, the status message is used. If not, the last history message is used. If none of these are present, an empty event is returned.
-