Class ToolContext
java.lang.Object
com.google.adk.agents.ReadonlyContext
com.google.adk.agents.CallbackContext
com.google.adk.tools.ToolContext
ToolContext object provides a structured context for executing tools or functions.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class CallbackContext
eventActionsFields inherited from class ReadonlyContext
invocationContext -
Method Summary
Modifier and TypeMethodDescriptionactions()static ToolContext.Builderbuilder(InvocationContext invocationContext) voidfunctionCallId(String functionCallId) voidRequests confirmation for the given function call.voidrequestConfirmation(@Nullable String hint) Requests confirmation for the given function call.voidrequestConfirmation(@Nullable String hint, @Nullable Object payload) Requests confirmation for the given function call.io.reactivex.rxjava3.core.Single<SearchMemoryResponse> searchMemory(String query) Searches the memory of the current user.voidsetActions(EventActions actions) voidtoolConfirmation(ToolConfirmation toolConfirmation) toString()Methods inherited from class CallbackContext
eventActions, eventId, listArtifacts, loadArtifact, loadArtifact, saveArtifact, stateModifier 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.
-
Method Details
-
actions
-
setActions
-
functionCallId
-
functionCallId
-
toolConfirmation
-
toolConfirmation
-
requestConfirmation
-
requestConfirmation
Requests confirmation for the given function call.- Parameters:
hint- A hint to the user on how to confirm the tool call.
-
requestConfirmation
public void requestConfirmation()Requests confirmation for the given function call. -
searchMemory
Searches the memory of the current user. -
builder
-
toBuilder
-
toString
-