Class Runner
java.lang.Object
com.google.adk.runner.Runner
- Direct Known Subclasses:
FirestoreDatabaseRunner, InMemoryRunner
用于运行 GenAI Agents 的主要类。
-
嵌套类概述
Nested ClassesModifier and TypeClassDescriptionstatic class“Builder for”是一个用于描述某种构建工具或框架的术语。它通常表示该工具/框架用于帮助开发者或系统管理员快速、高效地创建或构建特定类型的应用程序、系统或组件。例如:“Builder for Web Applications”(用于构建Web应用程序的工具)或“Builder for Cloud Services”(用于构建云服务的工具)。Runner. -
构造函数概述
ConstructorsModifierConstructorDescriptionRunner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService) 已弃用(Deprecated)。Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService) 已弃用(Deprecated)。使用Runner.Builder相反。Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService, List<? extends Plugin> plugins) 已弃用(Deprecated)。使用Runner.Builder相反。protectedRunner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService, List<? extends Plugin> plugins, @Nullable EventsCompactionConfig eventsCompactionConfig, @Nullable ContextCacheConfig contextCacheConfig) 已弃用(Deprecated)。使用Runner.Builder相反。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)。使用Runner.Builder相反。 -
方法概述
Modifier and TypeMethodDescriptionagent()appName()static Runner.Builderbuilder()io.reactivex.rxjava3.core.Completableclose()关闭所有插件和代码执行器,并释放所有相关资源。@Nullable BaseMemoryServicenode()返回该运行器所执行的工作流节点;如果该运行器执行的是代理树(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) 以基于调用的方式运行代理程序。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) 该命令用于运行代理程序,会恢复已有的任务(即继续执行之前暂停的任务),而不是启动一个新的任务。protected io.reactivex.rxjava3.core.Flowable<Event> runAsyncImpl(Session session, com.google.genai.types.Content newMessage, RunConfig runConfig, @Nullable Map<String, Object> stateDelta) 使用提供的 `Session` 对象异步运行代理程序。io.reactivex.rxjava3.core.Flowable<Event> runLive(SessionKey sessionKey, LiveRequestQueue liveRequestQueue, RunConfig runConfig) 检索会话信息,并以实时模式运行代理程序。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) 检索会话信息,并以实时模式运行代理程序。protected io.reactivex.rxjava3.core.Flowable<Event> runLiveImpl(Session session, @Nullable LiveRequestQueue liveRequestQueue, RunConfig runConfig) 以实时模式运行代理程序,并将生成的日志事件添加到会话记录中。
-
构造函数详细信息
-
Runner
@Deprecated public Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService) Deprecated.UseRunner.Builderinstead.创建一个新的……Runner. -
Runner
@Deprecated public Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService, @Nullable BaseMemoryService memoryService, List<? extends Plugin> plugins) Deprecated.UseRunner.Builderinstead.创建一个新的……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.UseRunner.Builderinstead.创建一个新的……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, @Nullable ResumabilityConfig resumabilityConfig) Deprecated.UseRunner.Builderinstead.创建一个新的……Runner使用可恢复性配置(resumability config.)。 -
Runner
@Deprecated public Runner(BaseAgent agent, String appName, BaseArtifactService artifactService, BaseSessionService sessionService) Deprecated.UseRunner.Builderinstead.创建一个新的……Runner.
-
-
方法详细信息(Method Details)
-
builder
-
agent
-
node
返回该运行器所执行的工作流节点;当它执行代理树(agent tree)时,返回空值。当它执行某个具体工作流节点时,会返回该节点的相关信息。agent()返回一个NodeViewAgent它就代表了那个东西(或那个人)。 -
appName
-
artifactService
-
sessionService
-
memoryService
-
pluginManager
-
close
public io.reactivex.rxjava3.core.Completable close()关闭所有插件和代码执行器,并释放所有相关资源。 -
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) 以基于调用的方式运行代理程序。TODO:将此代码段作为主要的实现方案。
- 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) 运行代理程序,会恢复现有的调用(即继续执行之前已开始的操作),而不是启动一个新的调用。该调用的具体执行细节由相关系统或框架负责处理。invocationId或者从函数返回的结果中获取(该结果是通过某种方式传递过来的)。newMessage代理检查点(Agent checkpoints)会从历史记录中重新获取所需的数据;如果当前活跃的代理(active agent)已经完成了相应的操作,那么该操作会被视为“无操作”(no-op)。而工作流节点(workflow node)的根节点(root node)则会根据该调用事件(invocation events)来重新计算自己的执行进度——即使应用程序本身无法继续执行(即无法恢复运行状态)。- 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) 使用提供的 `Session` 对象异步运行代理程序。- 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) -
runLive
public io.reactivex.rxjava3.core.Flowable<Event> runLive(String userId, String sessionId, LiveRequestQueue liveRequestQueue, RunConfig runConfig) 检索会话信息,并以实时模式运行代理程序。- 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) 检索会话信息,并以实时模式运行代理程序。- 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) 以实时模式运行代理程序,并将生成的日志事件添加到会话记录中。- Returns:
- stream of events from the agent.
-
Runner.Builder相反。