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.callbackContextData(Map<String, Object> callbackContextData) Sets the callback context data for the invocation.contextCacheConfig(ContextCacheConfig contextCacheConfig) Sets the context cache configuration for the current agent run.endInvocation(boolean endInvocation) Sets whether this invocation should be ended.eventsCompactionConfig(EventsCompactionConfig eventsCompactionConfig) Sets the events compaction configuration for the current agent run.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.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.
-
eventsCompactionConfig
@CanIgnoreReturnValue public InvocationContext.Builder eventsCompactionConfig(@Nullable EventsCompactionConfig eventsCompactionConfig) Sets the events compaction configuration for the current agent run.- Parameters:
eventsCompactionConfig- the events compaction configuration.- Returns:
- this builder instance for chaining.
-
contextCacheConfig
@CanIgnoreReturnValue public InvocationContext.Builder contextCacheConfig(@Nullable ContextCacheConfig contextCacheConfig) Sets the context cache configuration for the current agent run.- Parameters:
contextCacheConfig- the context cache configuration.- Returns:
- this builder instance for chaining.
-
callbackContextData
@CanIgnoreReturnValue public InvocationContext.Builder callbackContextData(Map<String, Object> callbackContextData) Sets the callback context data for the invocation.- Parameters:
callbackContextData- the callback context data.- Returns:
- this builder instance for chaining.
-
build
Builds theInvocationContextinstance.- Throws:
IllegalStateException- if any required parameters are missing.
-
branch(String)instead.