Class EventConverter
java.lang.Object
com.google.adk.a2a.converters.EventConverter
Converter for ADK Events to A2A Messages.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.common.collect.ImmutableList<io.a2a.spec.Part<?>> contentToParts(Optional<com.google.genai.types.Content> content, boolean isPartial) Converts a GenAI Content object to a list of A2A Parts.static StringReturns the context ID from the event.static @Nullable EventfindUserFunctionCall(List<Event> events) Returns the last user function call event from the list of events.static com.google.common.collect.ImmutableList<io.a2a.spec.Part<?>> messagePartsFromContext(InvocationContext context) Returns the parts from the context events that should be sent to the agent.static StringReturns the task ID from the event.
-
Field Details
-
ADK_TASK_ID_KEY
- See Also:
-
ADK_CONTEXT_ID_KEY
- See Also:
-
-
Method Details
-
taskId
Returns the task ID from the event.Task ID is stored in the event's custom metadata with the key
ADK_TASK_ID_KEY.- Parameters:
event- The event to get the task ID from.- Returns:
- The task ID, or an empty string if not found.
-
contextId
Returns the context ID from the event.Context ID is stored in the event's custom metadata with the key
ADK_CONTEXT_ID_KEY.- Parameters:
event- The event to get the context ID from.- Returns:
- The context ID, or an empty string if not found.
-
findUserFunctionCall
-
contentToParts
public static com.google.common.collect.ImmutableList<io.a2a.spec.Part<?>> contentToParts(Optional<com.google.genai.types.Content> content, boolean isPartial) Converts a GenAI Content object to a list of A2A Parts.- Parameters:
content- The GenAI Content object to convert.isPartial- Whether the content is partial.- Returns:
- A list of A2A Parts.
-
messagePartsFromContext
public static com.google.common.collect.ImmutableList<io.a2a.spec.Part<?>> messagePartsFromContext(InvocationContext context) Returns the parts from the context events that should be sent to the agent.All session events from the previous remote agent response (or the beginning of the session in case of the first agent invocation) are included into the A2A message. Events from other agents are presented as user messages and rephased as if a user was telling what happened in the session up to the point.
- Parameters:
context- The invocation context to get the parts from.- Returns:
- A list of A2A Parts.
-