strands.plugins.plugin
Plugin base class for extending agent functionality.
This module defines the Plugin base class, which provides a composable way to add behavior changes to agents through a standardized initialization pattern.
Plugin
Section titled “Plugin”class Plugin(ABC)Defined in: src/strands/plugins/plugin.py:15
Base class for objects that extend agent functionality.
Plugins provide a composable way to add behavior changes to agents. They are initialized with an agent instance and can register hooks, modify agent attributes, or perform other setup tasks.
Attributes:
name- A stable string identifier for the plugin
Example:
class MyPlugin(Plugin): name = "my-plugin"
def init_plugin(self, agent: Agent) -> None: agent.add_hook(self.on_model_call, BeforeModelCallEvent)@property@abstractmethoddef name() -> strDefined in: src/strands/plugins/plugin.py:37
A stable string identifier for the plugin.
init_plugin
Section titled “init_plugin”@abstractmethoddef init_plugin(agent: "Agent") -> None | Awaitable[None]Defined in: src/strands/plugins/plugin.py:42
Initialize the plugin with an agent instance.
Arguments:
agent- The agent instance to extend.