Class Runner
java.lang.Object
com.google.adk.runner.Runner
- Direct Known Subclasses:
FirestoreDatabaseRunner, InMemoryRunner
The main class for the GenAI Agents runner.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsModifierConstructorDescriptionRunner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService) Deprecated.Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService) Deprecated.UseRunner.Builderinstead.Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService, List<? extends Plugin> plugins) Deprecated.UseRunner.Builderinstead.protectedRunner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService, List<? extends Plugin> plugins, @Nullable EventsCompactionConfig eventsCompactionConfig, @Nullable ContextCacheConfig contextCacheConfig) Deprecated.UseRunner.Builderinstead.protectedRunner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService, List<? extends Plugin> plugins, @Nullable EventsCompactionConfig eventsCompactionConfig, @Nullable ContextCacheConfig contextCacheConfig, @Nullable ResumabilityConfig resumabilityConfig) Deprecated.UseRunner.Builderinstead. -
Method Summary
Modifier and TypeMethodDescriptionagent()appName()static Runner.Builderbuilder()io.reactivex.rxjava3.core.Completableclose()Closes all plugins, code executors, and releases any resources.@Nullable BaseMemoryServicenode()Returns the workflow node this runner runs, or empty when it runs an agent tree.io.reactivex.rxjava3.core.Flowable<Event> runAsync(SessionKey sessionKey, com.google.genai.types.Content newMessage) io.reactivex.rxjava3.core.Flowable<Event> runAsync(SessionKey sessionKey, com.google.genai.types.Content newMessage, RunConfig runConfig) io.reactivex.rxjava3.core.Flowable<Event> runAsync(SessionKey sessionKey, com.google.genai.types.Content newMessage, RunConfig runConfig, @Nullable Map<String, Object> stateDelta) io.reactivex.rxjava3.core.Flowable<Event> io.reactivex.rxjava3.core.Flowable<Event> runAsync(String userId, String sessionId, com.google.genai.types.Content newMessage, RunConfig runConfig) 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.io.reactivex.rxjava3.core.Flowable<Event> runAsync(String userId, String sessionId, @Nullable String invocationId, @Nullable com.google.genai.types.Content newMessage, RunConfig runConfig, @Nullable Map<String, Object> stateDelta) Runs the agent, resuming an existing invocation instead of starting a new one.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) Runs the agent in live mode.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.
-
Constructor Details
-
Runner
@Deprecated public Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService) Deprecated.UseRunner.Builderinstead.Creates a newRunner. -
Runner
@Deprecated public Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService, List<? extends Plugin> plugins) Deprecated.UseRunner.Builderinstead.Creates a newRunnerwith 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.UseRunner.Builderinstead.Creates a newRunnerwith 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, @Nullable ResumabilityConfig resumabilityConfig) Deprecated.UseRunner.Builderinstead.Creates a newRunnerwith a resumability config. -
Runner
@Deprecated public Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService) Deprecated.UseRunner.Builderinstead.Creates a newRunner.
-
-
Method Details
-
builder
-
agent
-
node
Returns the workflow node this runner runs, or empty when it runs an agent tree. When it runs a node,agent()returns aNodeViewAgentthat stands in for it. -
appName
-
artifactService
-
sessionService
-
memoryService
-
pluginManager
-
close
public io.reactivex.rxjava3.core.Completable close()Closes all plugins, code executors, and releases any resources. -
runAsync
-
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
Eventobjects generated by the agent during execution.
-
runAsync
-
runAsync
public io.reactivex.rxjava3.core.Flowable<Event> runAsync(SessionKey sessionKey, com.google.genai.types.Content newMessage, RunConfig runConfig) -
runAsync
public io.reactivex.rxjava3.core.Flowable<Event> runAsync(SessionKey sessionKey, com.google.genai.types.Content newMessage) -
runAsync
-
runAsync
@Experimental public io.reactivex.rxjava3.core.Flowable<Event> runAsync(String userId, String sessionId, @Nullable String invocationId, @Nullable com.google.genai.types.Content newMessage, RunConfig runConfig, @Nullable Map<String, Object> stateDelta) Runs the agent, resuming an existing invocation instead of starting a new one. The invocation is resolved frominvocationId, or from a function response carried bynewMessage; for a workflow node root, a plain message instead joins the invocation of a task that waits on the user. Agent checkpoints are rehydrated from history and an invocation whose active agent already finished resolves to a no-op, while a workflow node root rebuilds its progress from the invocation's events even when the app is not resumable.- Parameters:
userId- the user id of the session.sessionId- the session id.invocationId- the invocation to resume; may benullwhen it can be inferred fromnewMessage.newMessage- an optional message (typically a function response) to append before running.runConfig- the run configuration.stateDelta- optional state updates to merge into the session for this run.- Returns:
- the events generated while resuming, or an empty stream when there is nothing to resume.
- Throws:
IllegalStateException- if the app is not resumable and its root is an agent.IllegalArgumentException- if the invocation cannot be resolved.
-
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
Eventobjects 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.Canceling the returned stream still runs plugin afterRun callbacks once the agent has stopped. They run on the canceling thread, and cancellation does not wait for an asynchronous afterRun to finish.
- 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.Canceling the returned stream still runs plugin afterRun callbacks once the agent has stopped. They run on the canceling thread, and cancellation does not wait for an asynchronous afterRun to finish.
- 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.Canceling the returned stream still runs plugin afterRun callbacks once the agent has stopped. They run on the canceling thread, and cancellation does not wait for an asynchronous afterRun to finish.
- 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.
-
Runner.Builderinstead.