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.voidstatic Event.Builderbuilder()Optional<com.google.genai.types.Content>content()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 StringOptional<com.google.genai.types.GroundingMetadata>The grounding metadata of the event.inthashCode()final booleanReturns whether the event has a trailing code execution result.id()The event id.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.partial()partial is true for incomplete chunks from the LLM streaming response.voidsetActions(EventActions actions) voidvoidsetAvgLogprobs(Optional<Double> avgLogprobs) voidsetContent(Optional<com.google.genai.types.Content> content) voidsetErrorCode(Optional<com.google.genai.types.FinishReason> errorCode) voidsetErrorMessage(Optional<String> errorMessage) voidsetFinishReason(Optional<com.google.genai.types.FinishReason> finishReason) voidsetGroundingMetadata(Optional<com.google.genai.types.GroundingMetadata> groundingMetadata) voidvoidsetInterrupted(Optional<Boolean> interrupted) voidsetInvocationId(String invocationId) voidsetLongRunningToolIds(Optional<Set<String>> longRunningToolIds) voidsetModelVersion(Optional<String> modelVersion) voidsetPartial(Optional<Boolean> partial) voidsetTimestamp(long timestamp) voidsetTurnComplete(Optional<Boolean> turnComplete) voidsetUsageMetadata(Optional<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
-
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
-
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
-
setFinishReason
-
errorMessage
-
setErrorMessage
-
usageMetadata
-
setUsageMetadata
public void setUsageMetadata(Optional<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.
-
branch
-
groundingMetadata
The grounding metadata of the event. -
setGroundingMetadata
public void setGroundingMetadata(Optional<com.google.genai.types.GroundingMetadata> groundingMetadata) -
modelVersion
The model version used to generate the response. -
setModelVersion
-
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. -
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
Parses an event from a JSON string. -
toBuilder
Creates a builder pre-filled with this event's values. -
equals
-
toString
-
hashCode
public int hashCode()
-