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.build()Builds theInvocationContextinstance.callbackContextData(Map<String, Object> callbackContextData) Sets the callback context data for the invocation.contextCacheConfig(@Nullable ContextCacheConfig contextCacheConfig) Sets the context cache configuration for the current agent run.endInvocation(boolean endInvocation) Sets whether this invocation should be ended.eventsCompactionConfig(@Nullable EventsCompactionConfig eventsCompactionConfig) Sets the events compaction configuration for the current agent run.instantSource(@Nullable InstantSource instantSource) Sets the instant source for the invocation;null(the default) selectsInstantSource.system().invocationId(String invocationId) Sets the unique ID for the invocation.liveRequestQueue(@Nullable LiveRequestQueue liveRequestQueue) Sets the queue for managing live requests.memoryService(BaseMemoryService memoryService) Sets the memory service for accessing agent memory.pluginManager(Plugin pluginManager) Sets the plugin manager for accessing tools and plugins.resumabilityConfig(@Nullable ResumabilityConfig resumabilityConfig) Sets the resumability configuration for the invocation.Sets the configuration for the current agent run.scheduler(@Nullable io.reactivex.rxjava3.core.Scheduler scheduler) Sets the scheduler for the invocation's internal fan-out; seeInvocationContext.scheduler().Sets the session associated with this invocation.sessionService(BaseSessionService sessionService) Sets the session service for managing session state.userContent(@Nullable com.google.genai.types.Content userContent) Sets the user content that triggered this invocation.uuidProvider(@Nullable UuidProvider uuidProvider) Sets the UUID provider for the invocation;null(the default) selectsUuidProvider.SYSTEM.
-
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
@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
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(@Nullable 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.
-
resumabilityConfig
@CanIgnoreReturnValue public InvocationContext.Builder resumabilityConfig(@Nullable ResumabilityConfig resumabilityConfig) Sets the resumability configuration for the invocation.- Parameters:
resumabilityConfig- the resumability configuration.- Returns:
- this builder instance for chaining.
-
scheduler
@CanIgnoreReturnValue public InvocationContext.Builder scheduler(@Nullable io.reactivex.rxjava3.core.Scheduler scheduler) Sets the scheduler for the invocation's internal fan-out; seeInvocationContext.scheduler().null(the default) selectsSchedulers.io().- Parameters:
scheduler- the scheduler, ornullfor the default.- 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.
-
instantSource
@CanIgnoreReturnValue public InvocationContext.Builder instantSource(@Nullable InstantSource instantSource) Sets the instant source for the invocation;null(the default) selectsInstantSource.system().- Parameters:
instantSource- the source of the current time, ornullfor the default.- Returns:
- this builder instance for chaining.
-
uuidProvider
@CanIgnoreReturnValue public InvocationContext.Builder uuidProvider(@Nullable UuidProvider uuidProvider) Sets the UUID provider for the invocation;null(the default) selectsUuidProvider.SYSTEM.- Parameters:
uuidProvider- the provider for new unique identifiers, ornullfor the default.- Returns:
- this builder instance for chaining.
-
build
Builds theInvocationContextinstance.- Throws:
IllegalStateException- if any required parameters are missing.
-