strands.plugins.registry
Plugin registry for managing plugins attached to an agent.
This module provides the _PluginRegistry class for tracking and managing plugins that have been initialized with an agent instance.
_PluginRegistry
Section titled “_PluginRegistry”class _PluginRegistry()Defined in: src/strands/plugins/registry.py:21
Registry for managing plugins attached to an agent.
The _PluginRegistry tracks plugins that have been initialized with an agent, providing methods to add plugins and invoke their initialization.
Example:
registry = _PluginRegistry(agent)
class MyPlugin(Plugin): name = "my-plugin"
def init_plugin(self, agent: Agent) -> None: pass
plugin = MyPlugin()registry.add_and_init(plugin)__init__
Section titled “__init__”def __init__(agent: "Agent") -> NoneDefined in: src/strands/plugins/registry.py:42
Initialize a plugin registry with an agent reference.
Arguments:
agent- The agent instance that plugins will be initialized with.
add_and_init
Section titled “add_and_init”def add_and_init(plugin: Plugin) -> NoneDefined in: src/strands/plugins/registry.py:51
Add and initialize a plugin with the agent.
This method registers the plugin and calls its init_plugin method. Handles both sync and async init_plugin implementations automatically.
Arguments:
plugin- The plugin to add and initialize.
Raises:
ValueError- If a plugin with the same name is already registered.