Base未来插件(Plugin)

abstract class BaseFuturePlugin(pluginName: String) : Plugin

Java-friendly base for implementing a Plugin -- the cross-cutting interception point. The engine's Plugin has 13 suspend callbacks plus close(), every one with a default body. This base final-overrides all 13 and re-exposes each as a CompletableFuture-returning hook whose result is the outcome; each default hook completes with the value that leaves execution unchanged. Return the future promptly and do any blocking work inside it, not before returning it.

Each hook mirrors its engine callback's shape: those whose callback returns a CallbackChoice resolve to one too (build it with Choices -- Choices.proceed to continue, Choices.breakWith to short-circuit), and the rest resolve to a replacement value. To leave execution unchanged, resolve to the original value, exactly as the default hooks do.

构造函数(Constructors)

Link copied to clipboard
constructor(pluginName: String)

属性(Properties)

Link copied to clipboard
open override val name: String

该插件的唯一名称。

函数

Link copied to clipboard
suspend override fun afterAgent(context: CallbackContext): CallbackChoice<Unit, Content>

当某个特定的代理完成其处理任务后,会执行相应的回调函数。

Link copied to clipboard
suspend override fun afterModel(context: CallbackContext, response: LlmResponse): LlmResponse

在接收到大型语言模型(LLM)的响应后,会执行该回调函数。

Link copied to clipboard
suspend override fun afterRun(invocationContext: InvocationContext)

回调函数在 ADK 运行器完成执行后,或者调用者提前停止数据收集后(例如由于某种原因)被执行。 first() 或者 take(n))或者它的收集器抛出异常(exception)。

Link copied to clipboard
suspend override fun afterTool(context: ToolContext, tool: BaseTool, args: Map<String, Any?>, result: Map<String, Any?>): Map<String, Any?>

回调函数在工具运行完成后执行,或者在该工具运行之前的回调函数完成其任务后执行。

Link copied to clipboard

回调函数在某个特定代理开始处理任务之前被执行。

Link copied to clipboard
suspend override fun beforeModel(context: CallbackContext, request: LlmRequest): CallbackChoice<LlmRequest, LlmResponse>

回调函数在向大型语言模型(LLM)发送请求之前被执行。

Link copied to clipboard
suspend override fun beforeRun(invocationContext: InvocationContext): CallbackChoice<Unit, Content>

回调函数在 ADK 运行器开始执行主循环之前被调用。

Link copied to clipboard
suspend override fun beforeTool(context: ToolContext, tool: BaseTool, args: Map<String, Any?>): CallbackChoice<Map<String, Any?>, Map<String, Any?>>

回调函数在工具被调用之前执行。

Link copied to clipboard
open override fun close()

当运行器(runner)被关闭时,会执行此方法。

Link copied to clipboard
suspend override fun onEvent(invocationContext: InvocationContext, event: Event): Event

当代理在执行过程中触发某个事件时,会执行此回调函数。

Link copied to clipboard
suspend override fun onModelError(context: CallbackContext, request: LlmRequest, error: Throwable): CallbackChoice<Unit, LlmResponse>

当在大型语言模型(LLM)的交互过程中发生错误时,会执行此回调函数。

Link copied to clipboard
suspend override fun onRunError(invocationContext: InvocationContext, error: Throwable)

当 ADK 运行器运行失败时,或者在其他特定情况下,会执行此回调函数。 afterRun 在调用者提前停止数据收集后,程序会失败(即无法继续执行)。

Link copied to clipboard
suspend override fun onToolError(context: ToolContext, tool: BaseTool, args: Map<String, Any?>, error: Throwable): CallbackChoice<Unit, Map<String, Any?>>

当工具调用过程中发生错误时,会执行此回调函数。

Link copied to clipboard
suspend override fun onUserMessage(invocationContext: InvocationContext, userMessage: Content): Content

当在调用开始之前接收到用户消息时,会执行此回调函数。