Class Event
java.lang.Object
com.google.adk.JsonBaseModel
com.google.adk.events.Event
Represents an event in a session.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionactions()author()The author of the event, it could be the name of the agent or "user" literal.branch()The branch of the event.voidSets the branch for this event.static Event.Builderbuilder()Context cache state of the LLM response this event carries.Optional<com.google.genai.types.Content> content()The custom metadata of the event.booleanOptional<com.google.genai.types.FinishReason> final booleanReturns true if this is a final response.Optional<com.google.genai.types.FinishReason> static EventParses an event from a JSON string.final com.google.common.collect.ImmutableList<com.google.genai.types.FunctionCall> Returns all function calls from this event.final com.google.common.collect.ImmutableList<com.google.genai.types.FunctionResponse> Returns all function responses from this event.static StringReturns a random event id.Optional<com.google.genai.types.GroundingMetadata> The grounding metadata of the event.inthashCode()final booleanReturns whether this event carries a pending long-running tool call (e.g.final booleanReturns whether the event has a trailing code execution result.id()The event id.Optional<com.google.genai.types.Transcription> Input transcription.Id of the invocation that this event belongs to.Set of ids of the long running function calls.The model version used to generate the response.nodeInfo()Identifies the workflow-node activation that emitted this event; outside a workflow, this value is empty or has an empty path.output()For a workflow node, returns the value handed to successors, distinct fromcontent(), or empty when the event carries no node output.Optional<com.google.genai.types.Transcription> Output transcription.partial()partial is true for incomplete chunks from the LLM streaming response.voidsetActions(EventActions actions) voidvoidsetAvgLogprobs(@Nullable Double avgLogprobs) voidsetCacheMetadata(@Nullable CacheMetadata cacheMetadata) voidsetContent(@Nullable com.google.genai.types.Content content) voidsetCustomMetadata(@Nullable List<com.google.genai.types.CustomMetadata> customMetadata) voidsetErrorCode(@Nullable com.google.genai.types.FinishReason errorCode) voidsetErrorMessage(@Nullable String errorMessage) voidsetFinishReason(@Nullable com.google.genai.types.FinishReason finishReason) voidsetFinishReason(Optional<com.google.genai.types.FinishReason> finishReason) Deprecated.voidsetGroundingMetadata(@Nullable com.google.genai.types.GroundingMetadata groundingMetadata) voidvoidsetInputTranscription(@Nullable com.google.genai.types.Transcription inputTranscription) voidsetInterrupted(@Nullable Boolean interrupted) voidsetInvocationId(String invocationId) voidsetLongRunningToolIds(@Nullable Set<String> longRunningToolIds) voidsetModelVersion(@Nullable String modelVersion) voidsetNodeInfo(@Nullable NodeInfo nodeInfo) voidvoidsetOutputTranscription(@Nullable com.google.genai.types.Transcription outputTranscription) voidsetPartial(@Nullable Boolean partial) voidsetTimestamp(long timestamp) voidsetTurnComplete(@Nullable Boolean turnComplete) voidsetUsageMetadata(@Nullable com.google.genai.types.GenerateContentResponseUsageMetadata usageMetadata) final StringConverts the event content into a readable string.longThe timestamp of the event.Creates a builder pre-filled with this event's values.toString()Optional<com.google.genai.types.GenerateContentResponseUsageMetadata> Methods inherited from class JsonBaseModel
fromJsonNode, fromJsonString, getMapper, toJson, toJsonNode, toJsonStringModifier and TypeMethodDescriptionstatic <T extends JsonBaseModel>
TfromJsonNode(com.fasterxml.jackson.databind.JsonNode jsonNode, Class<T> clazz) Deserializes a JsonNode to an object of the given type.static <T extends JsonBaseModel>
TfromJsonString(String jsonString, Class<T> clazz) Deserializes a Json string to an object of the given type.static com.fasterxml.jackson.databind.ObjectMapperReturns the mutable ObjectMapper instance used by ADK.toJson()Serializes this object (i.e., the ObjectMappper instance used by ADK) to a Json string.protected static com.fasterxml.jackson.databind.JsonNodetoJsonNode(Object object) Serializes an object to a JsonNode.static StringtoJsonString(Object object) Serializes an object to a Json string.
-
Method Details
-
generateEventId
Returns a random event id. Agents, tools, and plugins that build events inside an invocation should useInvocationContext.newUuid()instead so the id follows itsUuidProvider. -
id
The event id. -
setId
-
invocationId
Id of the invocation that this event belongs to. -
setInvocationId
-
author
The author of the event, it could be the name of the agent or "user" literal. -
setAuthor
-
content
-
setContent
public void setContent(@Nullable com.google.genai.types.Content content) -
actions
-
setActions
-
longRunningToolIds
-
setLongRunningToolIds
-
partial
-
setPartial
-
turnComplete
-
setTurnComplete
-
errorCode
-
finishReason
-
setErrorCode
public void setErrorCode(@Nullable com.google.genai.types.FinishReason errorCode) -
setFinishReason
Deprecated.UsesetFinishReason(FinishReason)withfinishReason.orElse(null)instead.Sets the finish reason from anOptional. -
setFinishReason
public void setFinishReason(@Nullable com.google.genai.types.FinishReason finishReason) -
errorMessage
-
setErrorMessage
-
usageMetadata
-
setUsageMetadata
public void setUsageMetadata(@Nullable com.google.genai.types.GenerateContentResponseUsageMetadata usageMetadata) -
avgLogprobs
-
setAvgLogprobs
-
interrupted
-
setInterrupted
-
branch
-
branch
Sets the branch for this event.Format: agentA.agentB.agentC — shows hierarchy of nested agents.
- Parameters:
branch- Branch identifier.
-
groundingMetadata
The grounding metadata of the event. -
setGroundingMetadata
public void setGroundingMetadata(@Nullable com.google.genai.types.GroundingMetadata groundingMetadata) -
customMetadata
-
setCustomMetadata
-
modelVersion
-
setModelVersion
-
inputTranscription
Input transcription. The transcription is independent to the model turn which means it doesn't imply any ordering between transcription and model turn. -
setInputTranscription
public void setInputTranscription(@Nullable com.google.genai.types.Transcription inputTranscription) -
outputTranscription
Output transcription. The transcription is independent to the model turn which means it doesn't imply any ordering between transcription and model turn. -
setOutputTranscription
public void setOutputTranscription(@Nullable com.google.genai.types.Transcription outputTranscription) -
output
For a workflow node, returns the value handed to successors, distinct fromcontent(), or empty when the event carries no node output. Holds any value Jackson can serialize, such as a JSON-native value or aContent. An event read from JSON holds the JSON-native form (a map with string keys, a list, a string, a number, or a boolean). -
setOutput
-
nodeInfo
Identifies the workflow-node activation that emitted this event; outside a workflow, this value is empty or has an empty path. -
setNodeInfo
-
cacheMetadata
Context cache state of the LLM response this event carries. The next request of the same agent reads it to reuse or refresh the cache. -
setCacheMetadata
-
timestamp
public long timestamp()The timestamp of the event. -
setTimestamp
public void setTimestamp(long timestamp) -
functionCalls
public final com.google.common.collect.ImmutableList<com.google.genai.types.FunctionCall> functionCalls()Returns all function calls from this event. -
functionResponses
public final com.google.common.collect.ImmutableList<com.google.genai.types.FunctionResponse> functionResponses()Returns all function responses from this event. -
hasTrailingCodeExecutionResult
public final boolean hasTrailingCodeExecutionResult()Returns whether the event has a trailing code execution result. -
hasPendingLongRunningToolCall
public final boolean hasPendingLongRunningToolCall()Returns whether this event carries a pending long-running tool call (e.g. a human-in-the-loop request) whose result is deferred until the caller supplies it later. -
finalResponse
public final boolean finalResponse()Returns true if this is a final response. -
stringifyContent
Converts the event content into a readable string.Includes text, function calls, and responses.
- Returns:
- Stringified content.
-
builder
-
fromJson
-
toBuilder
Creates a builder pre-filled with this event's values. -
equals
-
toString
-
hashCode
-
setFinishReason(FinishReason)withfinishReason.orElse(null)instead.