Package com.google.adk.events
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.Returns the isolated conversation this event belongs to, such as a delegated task, so an agent's model history can keep only events from its own scope.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.nodeName()Returns the name of the workflow node that emitted this event, fromNodeInfo.name().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) voidsetIsolationScope(@Nullable String isolationScope) 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 com.google.adk.JsonBaseModel
fromJsonNode, fromJsonString, getMapper, toJson, toJsonNode, toJsonString
-
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
Set of ids of the long running function calls. Agent client will know from this field about which function call is long running. -
setLongRunningToolIds
-
partial
partial is true for incomplete chunks from the LLM streaming response. The last chunk's partial is False. -
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
The branch of the event. The format is like agent_1.agent_2.agent_3, where agent_1 is the parent of agent_2, and agent_2 is the parent of agent_3. Branch is used when multiple sub-agent shouldn't see their peer agents' conversation history. -
branch
Sets the branch for this event.Format: agentA.agentB.agentC — shows hierarchy of nested agents.
- Parameters:
branch- Branch identifier.
-
isolationScope
Returns the isolated conversation this event belongs to, such as a delegated task, so an agent's model history can keep only events from its own scope. Returns empty when the event is not scoped. This field is internal to the framework and may change without notice. -
setIsolationScope
-
groundingMetadata
The grounding metadata of the event. -
setGroundingMetadata
public void setGroundingMetadata(@Nullable com.google.genai.types.GroundingMetadata groundingMetadata) -
customMetadata
The custom metadata of the event. -
setCustomMetadata
-
modelVersion
The model version used to generate the response. -
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. -
nodeName
Returns the name of the workflow node that emitted this event, fromNodeInfo.name(). Empty outside a workflow and on an event that carries any agent state or ends an agent. ADK Python'sEvent.node_namereturns an empty string instead and ignores an empty agent state. -
stringifyContent
Converts the event content into a readable string.Includes text, function calls, and responses.
- Returns:
- Stringified content.
-
builder
-
fromJson
Parses an event from a JSON string. -
toBuilder
Creates a builder pre-filled with this event's values. -
equals
-
toString
-
hashCode
public int hashCode()
-
setFinishReason(FinishReason)withfinishReason.orElse(null)instead.