Class InvocationContext.Builder

java.lang.Object
com.google.adk.agents.InvocationContext.Builder
Enclosing class:
InvocationContext

public static class InvocationContext.Builder extends Object
Builder for InvocationContext.
  • 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

      @CanIgnoreReturnValue public InvocationContext.Builder pluginManager(Plugin 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.
      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.
      Use branch(String) instead.
      Sets the branch ID for the invocation.
      Parameters:
      branch - the branch ID for the invocation.
      Returns:
      this builder instance for chaining.
    • branch

      @CanIgnoreReturnValue public InvocationContext.Builder branch(String branch)
      Sets the branch ID for the invocation.
      Parameters:
      branch - the branch ID for the invocation.
      Returns:
      this builder instance for chaining.
    • invocationId

      @CanIgnoreReturnValue public InvocationContext.Builder invocationId(String invocationId)
      Sets the unique ID for the invocation.
      Parameters:
      invocationId - the unique ID for the invocation.
      Returns:
      this builder instance for chaining.
    • agent

      @CanIgnoreReturnValue public InvocationContext.Builder agent(BaseAgent agent)
      Sets the agent being invoked.
      Parameters:
      agent - the agent being invoked; required.
      Returns:
      this builder instance for chaining.
    • session

      @CanIgnoreReturnValue public InvocationContext.Builder session(Session 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

      @CanIgnoreReturnValue public InvocationContext.Builder runConfig(RunConfig 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

      @CanIgnoreReturnValue public InvocationContext.Builder endInvocation(boolean 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

      public InvocationContext build()
      Builds the InvocationContext instance.
      Throws:
      IllegalStateException - if any required parameters are missing.