Class Runner
java.lang.Object
com.google.adk.runner.Runner
- Direct Known Subclasses:
InMemoryRunner
The main class for the GenAI Agents runner.
-
Constructor Summary
ConstructorsConstructorDescriptionRunner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService) Creates a newRunner. -
Method Summary
Modifier and TypeMethodDescriptionagent()appName()io.reactivex.rxjava3.core.Flowable<Event> Runs the agent in the standard mode using a provided Session object.io.reactivex.rxjava3.core.Flowable<Event> Asynchronously runs the agent for a given user and session, processing a new message and using a defaultRunConfig.io.reactivex.rxjava3.core.Flowable<Event> runAsync(String userId, String sessionId, com.google.genai.types.Content newMessage, RunConfig runConfig) Runs the agent in the standard mode.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.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.io.reactivex.rxjava3.core.Flowable<Event> runWithSessionId(String sessionId, com.google.genai.types.Content newMessage, RunConfig runConfig) Runs the agent asynchronously with a default user ID.
-
Constructor Details
-
Runner
public Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService) Creates a newRunner.
-
-
Method Details
-
agent
-
appName
-
artifactService
-
sessionService
-
runAsync
public io.reactivex.rxjava3.core.Flowable<Event> runAsync(String userId, String sessionId, com.google.genai.types.Content newMessage, RunConfig runConfig) Runs the agent in the standard mode.- 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.- Returns:
- A Flowable stream of
Eventobjects 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) Asynchronously runs the agent for a given user and session, processing a new message and using a defaultRunConfig.This method initiates an agent execution within the specified session, appending the provided new message to the session's history. It utilizes a default
RunConfigto control execution parameters. The method returns a stream ofEventobjects representing the agent's activity during the run.- Parameters:
userId- The ID of the user initiating the session.sessionId- The ID of the session in which the agent will run.newMessage- The newContentmessage to be processed by the agent.- Returns:
- A
FlowableemittingEventobjects generated by the agent.
-
runAsync
public io.reactivex.rxjava3.core.Flowable<Event> runAsync(Session session, com.google.genai.types.Content newMessage, RunConfig runConfig) Runs the agent in the standard mode 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.- 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, 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
-