Class ToolContext
java.lang.Object
com.google.adk.agents.ReadonlyContext
com.google.adk.agents.Context
com.google.adk.agents.CallbackContext
com.google.adk.tools.ToolContext
ToolContext object provides a structured context for executing tools or functions.
Extends CallbackContext (and through it Context); BaseTool.runAsync(Map, ToolContext)
and tool callbacks take this type.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class Context
eventActionsModifier and TypeFieldDescriptionprotected EventActionsThe event actions that record this context's changes.Fields inherited from class ReadonlyContext
invocationContext -
Method Summary
Modifier and TypeMethodDescriptionstatic ToolContext.Builderbuilder(InvocationContext invocationContext) voidsetActions(EventActions actions) toString()Methods inherited from class Context
actions, attemptCount, emit, emit, eventActions, eventAuthor, eventAuthor, eventId, functionCallId, functionCallId, listArtifacts, loadArtifact, loadArtifact, output, requestConfirmation, requestConfirmation, requestConfirmation, requireNodeState, resumeInputs, routes, routes, runNode, runNode, runNode, saveArtifact, searchMemory, state, toolConfirmation, toolConfirmationModifier and TypeMethodDescriptionactions()Returns the sameEventActionsasContext.eventActions().final intReturns the number of the attempt this workflow node is on, counting from 1; each retry adds one.final voidSendseventfrom this workflow node'sFunctionNodebody, after the events of earlier calls and before the output.final voidemit(com.google.genai.types.Content message) Sendsmessageas an event without an output, asContext.emit(Event)does.Returns theEventActionsassociated with this context.final StringReturns the author of the events this workflow node emits, or empty to use the node's name.final voideventAuthor(String eventAuthor) Sets the author of the events this workflow node emits.eventId()Returns the ID of the event associated with this context, or null if there is none.Returns the ID of the function call that invoked the current tool, if any.voidfunctionCallId(@Nullable String functionCallId) Sets the ID of the function call that invoked the current tool, or clears it if null.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.output()Returns this workflow node's output, which is the output of itsuseAsOutputchild once that child emits one, or empty if it has none.voidRequests confirmation for the current function call.voidrequestConfirmation(@Nullable String hint) Requests confirmation for the current function call.voidrequestConfirmation(@Nullable String hint, @Nullable Object payload) Requests confirmation for the current function call.final NodeExecutionStateReturns the state of the workflow node run this context belongs to.Returns the user's answers to the requests for input and long-running calls that this workflow node or its descendants made in an earlier turn, keyed by interrupt ID.routes()Returns the routes this workflow node selected, or empty if it made no routing decision.final voidSelects this workflow node's routes, which decide the outgoing edges to follow, replacing any earlier selection.final io.reactivex.rxjava3.core.Maybe<Object> Runsnodeas a child of this workflow node without an input, asContext.runNode(Node, Object, RunNodeConfig)does with the defaultRunNodeConfig.final io.reactivex.rxjava3.core.Maybe<Object> Runsnodeas a child of this workflow node, asContext.runNode(Node, Object, RunNodeConfig)does with the defaultRunNodeConfig.final io.reactivex.rxjava3.core.Maybe<Object> runNode(Node node, @Nullable Object nodeInput, RunNodeConfig config) Returns aMaybethat, when subscribed, runsnodeas a child of this workflow node and emits the child's output, or completes empty if it has none.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.io.reactivex.rxjava3.core.Single<SearchMemoryResponse> searchMemory(String query) Searches the memory of the current user.state()Returns the delta-aware state of the current context.Returns the confirmation of the current tool call, if any.voidtoolConfirmation(@Nullable ToolConfirmation toolConfirmation) Sets the confirmation of the current tool call, or clears it if null.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
-
setActions
-
builder
-
toBuilder
-
toString
-