Class EventConverter
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.common.collect.ImmutableList<io.a2a.spec.Part<?>> answerParts(List<Event> events) Returns the parts of the user's answer to send to the remote agent whose call it answers.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.static StringReturns the context ID from the event.static @Nullable EventfindUserFunctionCall(List<Event> events) Returns the call event that the last event's first non-credential function response answers.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
Deprecated.UseAdkMetadataKey.TASK_ID.getType(), the key task IDs are recorded under.Legacy task ID key, read only for events with neithera2a:ID key.- See Also:
-
ADK_CONTEXT_ID_KEY
Deprecated.UseAdkMetadataKey.CONTEXT_ID.getType(), the key context IDs are recorded under.Legacy context ID key, read only for events with neithera2a:ID key.- See Also:
-
-
Method Details
-
taskId
Returns the task ID from the event.Task ID is stored in the event's custom metadata under
a2a:task_id, whereResponseConverterand ADK Python write it. An event with neithera2a:task_idnora2a:context_idis read from the legacyadk_task_idkey.- 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 under
a2a:context_id, whereResponseConverterand ADK Python write it. An event with neithera2a:task_idnora2a:context_idis read from the legacyadk_context_idkey.- Parameters:
event- The event to get the context ID from.- Returns:
- The context ID, or an empty string if not found.
-
findUserFunctionCall
Returns the call event that the last event's first non-credential function response answers.- Parameters:
events- The list of events to find the user function call event from.- Returns:
- The user function call event, or null if not found.
-
answerParts
@Experimental public static com.google.common.collect.ImmutableList<io.a2a.spec.Part<?>> answerParts(List<Event> events) Returns the parts of the user's answer to send to the remote agent whose call it answers. Credential parts are never sent, nor is text beside a function response, which an ADK runner rejects.- Parameters:
events- The session events, ending with the user's answer; must not be empty.- Returns:
- The answer's parts to send, possibly none.
-
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. Credential parts are left out.
- Parameters:
context- The invocation context to get the parts from.- Returns:
- A list of A2A Parts.
-
AdkMetadataKey.CONTEXT_ID.getType(), the key context IDs are recorded under.