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 com.google.adk.agents.ReadonlyContext
invocationContext -
Constructor Summary
ConstructorsConstructorDescriptionCallbackContext(InvocationContext invocationContext, EventActions eventActions) Initializes callback context. -
Method Summary
Modifier and TypeMethodDescriptionReturns the EventActions associated with this context.io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String filename, Optional<Integer> version) Loads an artifact from the artifact service associated with the current session.voidsaveArtifact(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 com.google.adk.agents.ReadonlyContext
agentName, branch, events, invocationId, sessionId, userContent
-
Field Details
-
eventActions
-
-
Constructor Details
-
CallbackContext
Initializes callback context.- Parameters:
invocationContext- Current invocation context.eventActions- Callback event actions.
-
-
Method Details
-
state
Returns the delta-aware state of the current callback.- Overrides:
statein classReadonlyContext
-
eventActions
Returns the EventActions associated with this context. -
loadArtifact
public io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String filename, Optional<Integer> version) Loads an artifact from the artifact service associated with the current session.- Parameters:
filename- Artifact file name.version- Artifact version (optional).- Returns:
- loaded part, or empty if not found.
- Throws:
IllegalStateException- if the artifact service is not initialized.
-
saveArtifact
Saves an artifact and records it as a delta for the current session.- Parameters:
filename- Artifact file name.artifact- Artifact content to save.- Throws:
IllegalStateException- if the artifact service is not initialized.
-