# Plugin

interface Plugin

Interface 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.

#### Inheritors

LoggingPlugin

## Properties

name
Link copied to clipboard
abstract val name: String

The unique name of the plugin.

## Functions

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

Callback executed after a specific agent finishes its processing.

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

Callback executed after an LLM response is received.

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

Callback executed after the ADK runner completes its execution.

afterTool
Link copied to clipboard
open suspend 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.

beforeAgent
Link copied to clipboard
open suspend fun beforeAgent(context: CallbackContext): CallbackChoice<EventActions, Content>

Callback executed before a specific agent starts processing.

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

Callback executed before an LLM request is sent.

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

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

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

Callback executed before a tool is invoked.

close
Link copied to clipboard
open suspend fun close()

Method executed when the runner is closed.

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

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

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

Callback executed when an error occurs during an LLM interaction.

onToolError
Link copied to clipboard
open suspend 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.

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

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