Class BasePlugin
java.lang.Object
com.google.adk.plugins.BasePlugin
- All Implemented Interfaces:
Plugin
- Direct Known Subclasses:
BigQueryAgentAnalyticsPlugin, ContextFilterPlugin, GlobalInstructionPlugin, LoggingPlugin, PluginManager, ReplayPlugin
Base class for creating plugins.
Plugins provide a structured way to intercept and modify agent, tool, and LLM behaviors at critical execution points in a callback manner. While agent callbacks apply to a particular agent, plugins applies globally to all agents added in the runner. Plugins are best used for adding custom behaviors like logging, monitoring, caching, or modifying requests and responses at key stages.
A plugin can implement one or more methods of callbacks, but should not implement the same method of callback for multiple times.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Plugin
afterAgentCallback, afterModelCallback, afterRunCallback, afterToolCallback, beforeAgentCallback, beforeModelCallback, beforeRunCallback, beforeToolCallback, close, onEventCallback, onModelErrorCallback, onToolErrorCallback, onUserMessageCallbackModifier and TypeMethodDescriptiondefault io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> afterAgentCallback(BaseAgent agent, CallbackContext callbackContext) Callback executed after an agent's primary logic has completed.default io.reactivex.rxjava3.core.Maybe<LlmResponse> afterModelCallback(CallbackContext callbackContext, LlmResponse llmResponse) Callback executed after a response is received from the model.default io.reactivex.rxjava3.core.CompletableafterRunCallback(InvocationContext invocationContext) Callback executed after an ADK runner run has completed.afterToolCallback(BaseTool tool, Map<String, Object> toolArgs, ToolContext toolContext, Map<String, Object> result) Callback executed after a tool has been called.default io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> beforeAgentCallback(BaseAgent agent, CallbackContext callbackContext) Callback executed before an agent's primary logic is invoked.default io.reactivex.rxjava3.core.Maybe<LlmResponse> beforeModelCallback(CallbackContext callbackContext, LlmRequest.Builder llmRequest) Callback executed before a request is sent to the model.default io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> beforeRunCallback(InvocationContext invocationContext) Callback executed before the ADK runner runs.beforeToolCallback(BaseTool tool, Map<String, Object> toolArgs, ToolContext toolContext) Callback executed before a tool is called.default io.reactivex.rxjava3.core.Completableclose()Method executed when the runner is closed.default io.reactivex.rxjava3.core.Maybe<Event> onEventCallback(InvocationContext invocationContext, Event event) Callback executed after an event is yielded from runner.default io.reactivex.rxjava3.core.Maybe<LlmResponse> onModelErrorCallback(CallbackContext callbackContext, LlmRequest.Builder llmRequest, Throwable error) Callback executed when a model call encounters an error.onToolErrorCallback(BaseTool tool, Map<String, Object> toolArgs, ToolContext toolContext, Throwable error) Callback executed when a tool call encounters an error.default io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> onUserMessageCallback(InvocationContext invocationContext, com.google.genai.types.Content userMessage) Callback executed when a user message is received before an invocation starts.
-
Field Details
-
name
-
-
Constructor Details
-
BasePlugin
Constructs a new plugin with the given name.- Parameters:
name- The name of the plugin.
-
-
Method Details
-
getName
-