pub struct EnhancedPluginManager { /* private fields */ }plugin only.Expand description
Manages enhanced plugins with priority-based pipeline execution.
Plugins are stored sorted by priority (ascending). All pipeline methods iterate plugins in this order, passing each plugin’s output as input to the next plugin in the chain.
§Thread Safety
EnhancedPluginManager is Send + Sync and can be shared across async tasks
via Arc<EnhancedPluginManager>.
Implementations§
Source§impl EnhancedPluginManager
impl EnhancedPluginManager
Sourcepub fn new(plugins: Vec<Arc<dyn EnhancedPlugin>>) -> EnhancedPluginManager
pub fn new(plugins: Vec<Arc<dyn EnhancedPlugin>>) -> EnhancedPluginManager
Creates a new EnhancedPluginManager with the given plugins.
Plugins are sorted by priority in ascending order using a stable sort, so plugins with the same priority retain their registration order.
§Examples
use std::sync::Arc;
use adk_plugin::{EnhancedPluginManager, EnhancedPlugin};
let plugins: Vec<Arc<dyn EnhancedPlugin>> = vec![
Arc::new(MyPlugin),
];
let manager = EnhancedPluginManager::new(plugins);Sourcepub fn with_config(
plugins: Vec<Arc<dyn EnhancedPlugin>>,
config: PluginManagerConfig,
) -> EnhancedPluginManager
pub fn with_config( plugins: Vec<Arc<dyn EnhancedPlugin>>, config: PluginManagerConfig, ) -> EnhancedPluginManager
Creates a new EnhancedPluginManager with custom configuration.
Sourcepub fn add_plugin(&mut self, plugin: Arc<dyn EnhancedPlugin>)
pub fn add_plugin(&mut self, plugin: Arc<dyn EnhancedPlugin>)
Adds a plugin after construction, re-sorting by priority.
The plugin is inserted and the entire list is re-sorted using a stable sort to maintain registration order for same-priority plugins.
Sourcepub fn context(&self) -> &Arc<PluginContext> ⓘ
pub fn context(&self) -> &Arc<PluginContext> ⓘ
Returns a reference to the shared plugin context.
The context is shared across all hook invocations and persists for the lifetime of this manager.
Sourcepub fn plugin_count(&self) -> usize
pub fn plugin_count(&self) -> usize
Returns the number of registered plugins.
Sourcepub fn plugin_names(&self) -> Vec<&str>
pub fn plugin_names(&self) -> Vec<&str>
Returns the names of all registered plugins in execution order.
Sourcepub async fn run_before_tool_call(
&self,
tool: Arc<dyn Tool>,
args: Value,
ctx: Arc<dyn CallbackContext>,
) -> Result<BeforeToolCallResult, AdkError>
pub async fn run_before_tool_call( &self, tool: Arc<dyn Tool>, args: Value, ctx: Arc<dyn CallbackContext>, ) -> Result<BeforeToolCallResult, AdkError>
Executes the before_tool_call pipeline across all plugins in priority order.
Each plugin receives the (possibly modified) arguments from the previous plugin.
If a plugin returns ShortCircuit, the pipeline stops and the synthetic result
is returned. If a plugin returns an error, the pipeline stops and the error
is propagated.
§Arguments
tool- The tool about to be executedargs- The initial tool call argumentsctx- The callback context for the current invocation
§Returns
Ok(BeforeToolCallResult::Continue(args))— final modified arguments for tool executionOk(BeforeToolCallResult::ShortCircuit(result))— synthetic result, skip tool executionErr(e)— pipeline error, skip tool execution
Sourcepub async fn run_after_tool_call(
&self,
tool: Arc<dyn Tool>,
args: &Value,
result: Value,
ctx: Arc<dyn CallbackContext>,
) -> Result<AfterToolCallResult, AdkError>
pub async fn run_after_tool_call( &self, tool: Arc<dyn Tool>, args: &Value, result: Value, ctx: Arc<dyn CallbackContext>, ) -> Result<AfterToolCallResult, AdkError>
Executes the after_tool_call pipeline across all plugins in priority order.
Each plugin receives the (possibly modified) result from the previous plugin.
The args parameter contains the final modified arguments from the before-hook
pipeline (not the original arguments).
§Arguments
tool- The tool that was executedargs- The final arguments used for tool execution (after before-hook modifications)result- The initial tool execution resultctx- The callback context for the current invocation
§Returns
Ok(AfterToolCallResult::Continue(result))— final modified resultErr(e)— pipeline error
Sourcepub async fn run_before_model_call(
&self,
request: LlmRequest,
ctx: Arc<dyn CallbackContext>,
) -> Result<BeforeModelCallResult, AdkError>
pub async fn run_before_model_call( &self, request: LlmRequest, ctx: Arc<dyn CallbackContext>, ) -> Result<BeforeModelCallResult, AdkError>
Executes the before_model_call pipeline across all plugins in priority order.
Each plugin receives the (possibly modified) request from the previous plugin.
If a plugin returns ShortCircuit, the pipeline stops and the synthetic response
is returned. If a plugin returns an error, the pipeline stops and the error
is propagated.
§Arguments
request- The initial LLM requestctx- The callback context for the current invocation
§Returns
Ok(BeforeModelCallResult::Continue(request))— final modified request for model callOk(BeforeModelCallResult::ShortCircuit(response))— synthetic response, skip model callErr(e)— pipeline error, skip model call
Sourcepub async fn run_after_model_call(
&self,
response: LlmResponse,
ctx: Arc<dyn CallbackContext>,
) -> Result<AfterModelCallResult, AdkError>
pub async fn run_after_model_call( &self, response: LlmResponse, ctx: Arc<dyn CallbackContext>, ) -> Result<AfterModelCallResult, AdkError>
Executes the after_model_call pipeline across all plugins in priority order.
Each plugin receives the (possibly modified) response from the previous plugin. If a plugin returns an error, the pipeline stops and the error is propagated.
§Arguments
response- The initial LLM responsectx- The callback context for the current invocation
§Returns
Ok(AfterModelCallResult::Continue(response))— final modified responseErr(e)— pipeline error