Class InvocationContext.Builder
java.lang.Object
com.google.adk.agents.InvocationContext.Builder
- Enclosing class:
InvocationContext
Builder for
InvocationContext.-
Method Summary
Modifier and TypeMethodDescriptionSets the agent being invoked.artifactService(BaseArtifactService artifactService) Sets the artifact service for persisting artifacts.Sets the branch ID for the invocation.Deprecated, for removal: This API element is subject to removal in a future version.build()Builds theInvocationContextinstance.endInvocation(boolean endInvocation) Sets whether this invocation should be ended.invocationId(String invocationId) Sets the unique ID for the invocation.liveRequestQueue(LiveRequestQueue liveRequestQueue) Sets the queue for managing live requests.liveRequestQueue(Optional<LiveRequestQueue> liveRequestQueue) Deprecated, for removal: This API element is subject to removal in a future version.UseliveRequestQueue(LiveRequestQueue)instead.memoryService(BaseMemoryService memoryService) Sets the memory service for accessing agent memory.pluginManager(Plugin pluginManager) Sets the plugin manager for accessing tools and plugins.resumabilityConfig(ResumabilityConfig resumabilityConfig) Sets the resumability configuration for the current agent run.Sets the configuration for the current agent run.Sets the session associated with this invocation.sessionService(BaseSessionService sessionService) Sets the session service for managing session state.userContent(com.google.genai.types.Content userContent) Sets the user content that triggered this invocation.userContent(Optional<com.google.genai.types.Content> userContent) Sets the user content that triggered this invocation.
-
Method Details
-
sessionService
@CanIgnoreReturnValue public InvocationContext.Builder sessionService(BaseSessionService sessionService) Sets the session service for managing session state.- Parameters:
sessionService- the session service to use; required.- Returns:
- this builder instance for chaining.
-
artifactService
@CanIgnoreReturnValue public InvocationContext.Builder artifactService(BaseArtifactService artifactService) Sets the artifact service for persisting artifacts.- Parameters:
artifactService- the artifact service to use; required.- Returns:
- this builder instance for chaining.
-
memoryService
@CanIgnoreReturnValue public InvocationContext.Builder memoryService(BaseMemoryService memoryService) Sets the memory service for accessing agent memory.- Parameters:
memoryService- the memory service to use.- Returns:
- this builder instance for chaining.
-
pluginManager
Sets the plugin manager for accessing tools and plugins.- Parameters:
pluginManager- the plugin manager to use.- Returns:
- this builder instance for chaining.
-
liveRequestQueue
@Deprecated(forRemoval=true) @CanIgnoreReturnValue public InvocationContext.Builder liveRequestQueue(Optional<LiveRequestQueue> liveRequestQueue) Deprecated, for removal: This API element is subject to removal in a future version.UseliveRequestQueue(LiveRequestQueue)instead.Sets the queue for managing live requests.- Parameters:
liveRequestQueue- the queue for managing live requests.- Returns:
- this builder instance for chaining.
-
liveRequestQueue
@CanIgnoreReturnValue public InvocationContext.Builder liveRequestQueue(@Nullable LiveRequestQueue liveRequestQueue) Sets the queue for managing live requests.- Parameters:
liveRequestQueue- the queue for managing live requests.- Returns:
- this builder instance for chaining.
-
branch
@Deprecated(forRemoval=true) @CanIgnoreReturnValue public InvocationContext.Builder branch(Optional<String> branch) Deprecated, for removal: This API element is subject to removal in a future version.Usebranch(String)instead.Sets the branch ID for the invocation.- Parameters:
branch- the branch ID for the invocation.- Returns:
- this builder instance for chaining.
-
branch
Sets the branch ID for the invocation.- Parameters:
branch- the branch ID for the invocation.- Returns:
- this builder instance for chaining.
-
invocationId
Sets the unique ID for the invocation.- Parameters:
invocationId- the unique ID for the invocation.- Returns:
- this builder instance for chaining.
-
agent
Sets the agent being invoked.- Parameters:
agent- the agent being invoked; required.- Returns:
- this builder instance for chaining.
-
session
Sets the session associated with this invocation.- Parameters:
session- the session associated with this invocation; required.- Returns:
- this builder instance for chaining.
-
userContent
@CanIgnoreReturnValue public InvocationContext.Builder userContent(Optional<com.google.genai.types.Content> userContent) Sets the user content that triggered this invocation.- Parameters:
userContent- the user content that triggered this invocation.- Returns:
- this builder instance for chaining.
-
userContent
@CanIgnoreReturnValue public InvocationContext.Builder userContent(com.google.genai.types.Content userContent) Sets the user content that triggered this invocation.- Parameters:
userContent- the user content that triggered this invocation.- Returns:
- this builder instance for chaining.
-
runConfig
Sets the configuration for the current agent run.- Parameters:
runConfig- the configuration for the current agent run.- Returns:
- this builder instance for chaining.
-
endInvocation
Sets whether this invocation should be ended.- Parameters:
endInvocation- whether this invocation should be ended.- Returns:
- this builder instance for chaining.
-
resumabilityConfig
@CanIgnoreReturnValue public InvocationContext.Builder resumabilityConfig(ResumabilityConfig resumabilityConfig) Sets the resumability configuration for the current agent run.- Parameters:
resumabilityConfig- the resumability configuration.- Returns:
- this builder instance for chaining.
-
build
Builds theInvocationContextinstance.- Throws:
IllegalStateException- if any required parameters are missing.
-
branch(String)instead.