Skip to main content

Module adapted_plugin

Module adapted_plugin 

Source
Available on crate feature plugin only.
Expand description

Adapter wrapping a legacy closure-based Plugin as an EnhancedPlugin.

The AdaptedPlugin struct bridges the existing closure-based plugin system to the new trait-based EnhancedPlugin interface, enabling legacy plugins to participate in the enhanced pipeline without modification.

§Overview

Legacy plugins use callbacks that receive only a CallbackContext for tool hooks, and (CallbackContext, LlmRequest) / (CallbackContext, LlmResponse) for model hooks. They cannot modify tool arguments or results directly. The adapter:

§Example

use adk_plugin::{AdaptedPlugin, Plugin, PluginConfig};

let legacy_plugin = Plugin::new(PluginConfig {
    name: "my-legacy-plugin".to_string(),
    before_tool: Some(Box::new(|ctx| {
        Box::pin(async move {
            tracing::info!("tool starting");
            Ok(None)
        })
    })),
    ..Default::default()
});

// Wrap with default priority (100)
let adapted = AdaptedPlugin::new(legacy_plugin, 100);

Structs§

AdaptedPlugin
Wraps a legacy closure-based Plugin as an EnhancedPlugin.