# 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.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `Runner.Builder`
  Builder for `Runner`.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  ``
  `Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService)`
  Deprecated.
  Use `Runner.Builder` instead.
  ``
  `Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService)`
  Deprecated.
  Use `Runner.Builder` instead.
  ``
  `Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService, List<? extends Plugin> plugins)`
  Deprecated.
  Use `Runner.Builder` instead.
  `protected`
  `Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService, List<? extends Plugin> plugins, @Nullable EventsCompactionConfig eventsCompactionConfig, @Nullable ContextCacheConfig contextCacheConfig)`
  Deprecated.
  Use `Runner.Builder` instead.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `BaseAgent`
  `agent()`
  `String`
  `appName()`
  `BaseArtifactService`
  `artifactService()`
  `static Runner.Builder`
  `builder()`
  `io.reactivex.rxjava3.core.Completable`
  `close()`
  Closes all plugins, code executors, and releases any resources.
  `@Nullable BaseMemoryService`
  `memoryService()`
  `PluginManager`
  `pluginManager()`
  `io.reactivex.rxjava3.core.Flowable<Event>`
  `runAsync(SessionKey sessionKey, com.google.genai.types.Content newMessage)`
  See `runAsync(String, String, Content, RunConfig, Map)`.
  `io.reactivex.rxjava3.core.Flowable<Event>`
  `runAsync(SessionKey sessionKey, com.google.genai.types.Content newMessage, RunConfig runConfig)`
  See `runAsync(String, String, Content, RunConfig, Map)`.
  `io.reactivex.rxjava3.core.Flowable<Event>`
  `runAsync(SessionKey sessionKey, com.google.genai.types.Content newMessage, RunConfig runConfig, @Nullable Map<String,Object> stateDelta)`
  See `runAsync(String, String, Content, RunConfig, Map)`.
  `io.reactivex.rxjava3.core.Flowable<Event>`
  `runAsync(String userId, String sessionId, com.google.genai.types.Content newMessage)`
  See `runAsync(String, String, Content, RunConfig, Map)`.
  `io.reactivex.rxjava3.core.Flowable<Event>`
  `runAsync(String userId, String sessionId, com.google.genai.types.Content newMessage, RunConfig runConfig)`
  See `runAsync(String, String, Content, RunConfig, Map)`.
  `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.
  `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.
  `io.reactivex.rxjava3.core.Flowable<Event>`
  `runLive(SessionKey sessionKey, LiveRequestQueue liveRequestQueue, RunConfig runConfig)`
  Retrieves the session and runs the agent in live mode.
  `io.reactivex.rxjava3.core.Flowable<Event>`
  `runLive(Session session, LiveRequestQueue liveRequestQueue, RunConfig runConfig)`
  `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.
  `protected io.reactivex.rxjava3.core.Flowable<Event>`
  `runLiveImpl(Session session, @Nullable LiveRequestQueue liveRequestQueue, RunConfig runConfig)`
  Runs the agent in live mode, appending generated events to the session.
  `BaseSessionService`
  `sessionService()`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Runner

    @Deprecated public Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService)
    Deprecated.
    Use `Runner.Builder` instead.
    Creates a new `Runner`.

  - ### Runner

    @Deprecated public Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService, List<? extends Plugin> plugins)
    Deprecated.
    Use `Runner.Builder` instead.
    Creates a new `Runner` with a list of plugins.

  - ### Runner

    @Deprecated protected Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService, List<? extends Plugin> plugins, @Nullable EventsCompactionConfig eventsCompactionConfig, @Nullable ContextCacheConfig contextCacheConfig)
    Deprecated.
    Use `Runner.Builder` instead.
    Creates a new `Runner` with a list of plugins.

  - ### Runner

    @Deprecated public Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService)
    Deprecated.
    Use `Runner.Builder` instead.
    Creates a new `Runner`.

- ## 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

    public @Nullable 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)
    See `runAsync(String, String, Content, RunConfig, Map)`.

  - ### 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(SessionKey sessionKey, com.google.genai.types.Content newMessage, RunConfig runConfig, @Nullable Map<String,Object> stateDelta)
    See `runAsync(String, String, Content, RunConfig, Map)`.

  - ### runAsync

    public io.reactivex.rxjava3.core.Flowable<Event> runAsync(SessionKey sessionKey, com.google.genai.types.Content newMessage, RunConfig runConfig)
    See `runAsync(String, String, Content, RunConfig, Map)`.

  - ### runAsync

    public io.reactivex.rxjava3.core.Flowable<Event> runAsync(SessionKey sessionKey, com.google.genai.types.Content newMessage)
    See `runAsync(String, String, Content, RunConfig, Map)`.

  - ### runAsync

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

  - ### 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)

  - ### 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.

  - ### runLive

    public io.reactivex.rxjava3.core.Flowable<Event> runLive(SessionKey sessionKey, 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.

  - ### runLiveImpl

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