BaseFuturePlugin

abstract class BaseFuturePlugin(pluginName: String) : Plugin

Java-friendly base for implementing a Plugin -- the cross-cutting interception point. The engine's Plugin has 12 suspend callbacks plus close(), every one with a default body. This base final-overrides all 12 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

The unique name of the plugin.

Functions

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

Callback executed after a specific agent finishes its processing.

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

Callback executed after an LLM response is received.

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

Callback executed after the ADK runner completes its execution.

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

Callback executed after a tool finishes its execution.

Link copied to clipboard

Callback executed before a specific agent starts processing.

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

Callback executed before an LLM request is sent.

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

Callback executed before the ADK runner starts the main execution loop.

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

Callback executed before a tool is invoked.

Link copied to clipboard
open override fun close()

Method executed when the runner is closed.

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

Callback executed when an event is yielded by an agent during execution.

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

Callback executed when an error occurs during an LLM interaction.

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

Callback executed when an error occurs during a tool invocation.

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

Callback executed when a user message is received before an invocation starts.