Class Runner

java.lang.Object
com.google.adk.runner.Runner
Direct Known Subclasses:
FirestoreDatabaseRunner, InMemoryRunner

public class Runner extends Object
The main class for the GenAI Agents runner.
  • Constructor Details

  • Method Details

    • builder

      public static Runner.Builder builder()
    • agent

      public BaseAgent agent()
    • appName

      public String appName()
    • artifactService

      public BaseArtifactService artifactService()
    • sessionService

      public BaseSessionService sessionService()
    • memoryService

      @Nullable public BaseMemoryService memoryService()
    • pluginManager

      public PluginManager pluginManager()
    • close

      public io.reactivex.rxjava3.core.Completable close()
      Closes all plugins, code executors, and releases any resources.
    • runAsync

      public io.reactivex.rxjava3.core.Flowable<Event> runAsync(String userId, String sessionId, com.google.genai.types.Content newMessage, RunConfig runConfig)
    • runAsync

      public io.reactivex.rxjava3.core.Flowable<Event> runAsync(String userId, String sessionId, com.google.genai.types.Content newMessage, RunConfig runConfig, @Nullable Map<String,Object> stateDelta)
      Runs the agent with an invocation-based mode.

      TODO: make this the main implementation.

      Parameters:
      userId - The ID of the user for the session.
      sessionId - The ID of the session to run the agent in.
      newMessage - The new message from the user to process.
      runConfig - Configuration for the agent run.
      stateDelta - Optional map of state updates to merge into the session for this run.
      Returns:
      A Flowable stream of Event objects generated by the agent during execution.
    • runAsync

      public io.reactivex.rxjava3.core.Flowable<Event> runAsync(String userId, String sessionId, com.google.genai.types.Content newMessage)
    • runAsync

      @Deprecated(since="0.4.0", forRemoval=true) public io.reactivex.rxjava3.core.Flowable<Event> runAsync(Session session, com.google.genai.types.Content newMessage, RunConfig runConfig)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use runAsync with sessionId.
    • runAsync

      @Deprecated(since="0.4.0", forRemoval=true) public io.reactivex.rxjava3.core.Flowable<Event> runAsync(Session session, com.google.genai.types.Content newMessage, RunConfig runConfig, @Nullable Map<String,Object> stateDelta)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use runAsync with sessionId.
      Runs the agent asynchronously using a provided Session object.
      Parameters:
      session - The session to run the agent in.
      newMessage - The new message from the user to process.
      runConfig - Configuration for the agent run.
      stateDelta - Optional map of state updates to merge into the session for this run.
      Returns:
      A Flowable stream of Event objects generated by the agent during execution.
    • runAsyncImpl

      protected io.reactivex.rxjava3.core.Flowable<Event> runAsyncImpl(Session session, com.google.genai.types.Content newMessage, RunConfig runConfig, @Nullable Map<String,Object> stateDelta)
      Runs the agent asynchronously using a provided Session object.
      Parameters:
      session - The session to run the agent in.
      newMessage - The new message from the user to process.
      runConfig - Configuration for the agent run.
      stateDelta - Optional map of state updates to merge into the session for this run.
      Returns:
      A Flowable stream of Event objects generated by the agent during execution.
    • runLive

      public io.reactivex.rxjava3.core.Flowable<Event> runLive(Session session, LiveRequestQueue liveRequestQueue, RunConfig runConfig)
      Runs the agent in live mode, appending generated events to the session.
      Returns:
      stream of events from the agent.
    • runLive

      public io.reactivex.rxjava3.core.Flowable<Event> runLive(String userId, String sessionId, LiveRequestQueue liveRequestQueue, RunConfig runConfig)
      Retrieves the session and runs the agent in live mode.
      Returns:
      stream of events from the agent.
      Throws:
      IllegalArgumentException - if the session is not found.
    • runWithSessionId

      @Deprecated(since="0.5.0", forRemoval=true) public io.reactivex.rxjava3.core.Flowable<Event> runWithSessionId(String sessionId, com.google.genai.types.Content newMessage, RunConfig runConfig)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Runs the agent asynchronously with a default user ID.
      Returns:
      stream of generated events.