Class CallbackContext
java.lang.Object
com.google.adk.agents.ReadonlyContext
com.google.adk.agents.CallbackContext
- Direct Known Subclasses:
ToolContext
The context of various callbacks for an agent invocation.
-
Field Summary
FieldsFields inherited from class ReadonlyContext
invocationContext -
Constructor Summary
ConstructorsConstructorDescriptionCallbackContext(InvocationContext invocationContext, EventActions eventActions) Initializes callback context.CallbackContext(InvocationContext invocationContext, EventActions eventActions, String eventId) Initializes callback context. -
Method Summary
Modifier and TypeMethodDescriptionReturns the EventActions associated with this context.eventId()Returns the ID of the event associated with this context.Lists the filenames of the artifacts attached to the current session.io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String filename) Loads the latest version of an artifact from the service.io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String filename, int version) Loads a specific version of an artifact from the service.io.reactivex.rxjava3.core.CompletablesaveArtifact(String filename, com.google.genai.types.Part artifact) Saves an artifact and records it as a delta for the current session.state()Returns the delta-aware state of the current callback.Methods inherited from class ReadonlyContext
agentName, branch, events, invocationContext, invocationId, sessionId, userContent, userIdModifier and TypeMethodDescriptionReturns the name of the agent currently running.branch()Returns the branch of the current invocation, if present.events()Returns an unmodifiable view of the events of the session.Returns the invocation context.Returns the ID of the current invocation.Returns the session ID.Optional<com.google.genai.types.Content> Returns the user content that initiated this invocation.userId()Returns the user ID.
-
Field Details
-
eventActions
-
-
Constructor Details
-
CallbackContext
Initializes callback context.- Parameters:
invocationContext- Current invocation context.eventActions- Callback event actions.
-
CallbackContext
public CallbackContext(InvocationContext invocationContext, EventActions eventActions, String eventId) Initializes callback context.- Parameters:
invocationContext- Current invocation context.eventActions- Callback event actions.eventId- The ID of the event associated with this context.
-
-
Method Details
-
state
Returns the delta-aware state of the current callback.- Overrides:
statein classReadonlyContext
-
eventActions
Returns the EventActions associated with this context. -
eventId
Returns the ID of the event associated with this context. -
listArtifacts
-
loadArtifact
Loads the latest version of an artifact from the service. -
loadArtifact
public io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String filename, int version) Loads a specific version of an artifact from the service. -
saveArtifact
public io.reactivex.rxjava3.core.Completable saveArtifact(String filename, com.google.genai.types.Part artifact) Saves an artifact and records it as a delta for the current session.- Parameters:
filename- Artifact file name.artifact- Artifact content to save.- Returns:
- a
Completablethat completes when the artifact is saved. - Throws:
IllegalStateException- if the artifact service is not initialized.
-