Plugins¶
Plugin system for extending AgentProbe with custom evaluators, adapters, reporters, and storage backends.
Base Classes¶
agentprobe.plugins.base
¶
Base plugin classes with lifecycle hooks and typed subclasses.
Plugins extend AgentProbe's functionality by implementing lifecycle hooks and providing factory methods for evaluators, adapters, reporters, or storage backends.
PluginBase
¶
Bases: ABC
Abstract base for all AgentProbe plugins.
Plugins implement lifecycle hooks that are called at various points during test execution. Subclasses should override only the hooks they need — default implementations are no-ops.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Unique plugin identifier. |
plugin_type |
PluginType
|
The type of extension this plugin provides. |
version |
str
|
Plugin version string. |
Source code in src/agentprobe/plugins/base.py
name
abstractmethod
property
¶
Return the unique plugin name.
plugin_type
abstractmethod
property
¶
Return the plugin type.
version
property
¶
Return the plugin version.
on_load()
¶
on_unload()
¶
on_test_start(test_name, **kwargs)
¶
Called before a test case begins execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
test_name
|
str
|
Name of the test about to run. |
required |
**kwargs
|
Any
|
Additional context. |
{}
|
on_test_end(test_name, **kwargs)
¶
Called after a test case completes execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
test_name
|
str
|
Name of the test that completed. |
required |
**kwargs
|
Any
|
Additional context. |
{}
|
on_suite_start(**kwargs)
¶
Called before a test suite begins execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional context. |
{}
|
on_suite_end(**kwargs)
¶
Called after a test suite completes execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional context. |
{}
|
EvaluatorPlugin
¶
Bases: PluginBase
Plugin that provides a custom evaluator.
Subclasses must implement create_evaluator() to return an object
satisfying :class:~agentprobe.core.protocols.EvaluatorProtocol.
Source code in src/agentprobe/plugins/base.py
plugin_type
property
¶
Return EVALUATOR type.
create_evaluator()
abstractmethod
¶
Create and return an evaluator instance.
Returns:
| Type | Description |
|---|---|
EvaluatorProtocol
|
An evaluator conforming to EvaluatorProtocol. |
AdapterPlugin
¶
Bases: PluginBase
Plugin that provides a custom adapter.
Subclasses must implement create_adapter() to return an object
satisfying :class:~agentprobe.core.protocols.AdapterProtocol.
Source code in src/agentprobe/plugins/base.py
plugin_type
property
¶
Return ADAPTER type.
create_adapter()
abstractmethod
¶
Create and return an adapter instance.
Returns:
| Type | Description |
|---|---|
AdapterProtocol
|
An adapter conforming to AdapterProtocol. |
ReporterPlugin
¶
Bases: PluginBase
Plugin that provides a custom reporter.
Subclasses must implement create_reporter() to return an object
satisfying :class:~agentprobe.core.protocols.ReporterProtocol.
Source code in src/agentprobe/plugins/base.py
plugin_type
property
¶
Return REPORTER type.
create_reporter()
abstractmethod
¶
Create and return a reporter instance.
Returns:
| Type | Description |
|---|---|
ReporterProtocol
|
A reporter conforming to ReporterProtocol. |
StoragePlugin
¶
Bases: PluginBase
Plugin that provides a custom storage backend.
Subclasses must implement create_storage() to return an object
satisfying :class:~agentprobe.core.protocols.StorageProtocol.
Source code in src/agentprobe/plugins/base.py
plugin_type
property
¶
Return STORAGE type.
create_storage()
abstractmethod
¶
Create and return a storage instance.
Returns:
| Type | Description |
|---|---|
StorageProtocol
|
A storage backend conforming to StorageProtocol. |
Registry¶
agentprobe.plugins.registry
¶
Plugin registry: stores and retrieves plugins by name and type.
Provides a simple dict-based registry with type filtering support.
PluginRegistry
¶
Registry for managing loaded plugins.
Stores plugins by name and provides lookup by name or type. Prevents duplicate registrations.
Source code in src/agentprobe/plugins/registry.py
register(plugin)
¶
Register a plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin
|
PluginBase
|
The plugin to register. |
required |
Raises:
| Type | Description |
|---|---|
PluginError
|
If a plugin with the same name is already registered. |
Source code in src/agentprobe/plugins/registry.py
unregister(name)
¶
Unregister a plugin by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The plugin name to remove. |
required |
Raises:
| Type | Description |
|---|---|
PluginError
|
If no plugin with the given name is registered. |
Source code in src/agentprobe/plugins/registry.py
get(name)
¶
Get a plugin by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The plugin name to look up. |
required |
Returns:
| Type | Description |
|---|---|
PluginBase | None
|
The plugin if found, otherwise None. |
list_plugins()
¶
Return all registered plugins.
Returns:
| Type | Description |
|---|---|
list[PluginBase]
|
A list of all plugins in registration order. |
list_by_type(plugin_type)
¶
Return all plugins of a given type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_type
|
PluginType
|
The type to filter by. |
required |
Returns:
| Type | Description |
|---|---|
list[PluginBase]
|
A list of matching plugins. |
Source code in src/agentprobe/plugins/registry.py
Loader¶
agentprobe.plugins.loader
¶
Plugin loader: discovers and loads plugins from entry points and paths.
Supports two discovery mechanisms:
1. Entry points (importlib.metadata) for installed packages.
2. File paths (importlib.util) for local plugin files.
PluginLoader
¶
Loads plugin classes from various sources.
Discovers and instantiates plugins from Python entry points, file paths, or direct class references.
Source code in src/agentprobe/plugins/loader.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
__init__(entry_point_group='agentprobe.plugins')
¶
Initialize the plugin loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entry_point_group
|
str
|
Entry point group name for discovery. |
'agentprobe.plugins'
|
load_from_entry_points()
¶
Discover and load plugins from installed package entry points.
Returns:
| Type | Description |
|---|---|
list[PluginBase]
|
A list of loaded plugin instances. |
Source code in src/agentprobe/plugins/loader.py
load_from_path(path)
¶
Load a plugin from a Python file path.
The file must contain exactly one class that subclasses PluginBase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the Python file containing the plugin. |
required |
Returns:
| Type | Description |
|---|---|
PluginBase
|
The loaded plugin instance. |
Raises:
| Type | Description |
|---|---|
PluginError
|
If the file cannot be loaded or contains no plugin class. |
Source code in src/agentprobe/plugins/loader.py
load_from_class(cls)
¶
Load a plugin from a direct class reference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
type[PluginBase]
|
The plugin class to instantiate. |
required |
Returns:
| Type | Description |
|---|---|
PluginBase
|
The loaded plugin instance. |
Raises:
| Type | Description |
|---|---|
PluginError
|
If the class is not a PluginBase subclass. |
Source code in src/agentprobe/plugins/loader.py
load_all(directories=None)
¶
Load plugins from entry points and optional directories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directories
|
list[str] | None
|
Additional directories to scan for .py plugin files. |
None
|
Returns:
| Type | Description |
|---|---|
list[PluginBase]
|
A list of all loaded plugin instances. |
Source code in src/agentprobe/plugins/loader.py
Manager¶
agentprobe.plugins.manager
¶
Plugin manager: orchestrates plugin lifecycle and event dispatch.
Coordinates loading, registration, lifecycle hooks, and factory collection across all loaded plugins.
PluginManager
¶
Orchestrates plugin lifecycle and event dispatch.
Manages the full lifecycle of plugins: loading from sources, registering, dispatching lifecycle events, and collecting factory-created objects from typed plugins.
Attributes:
| Name | Type | Description |
|---|---|---|
registry |
The plugin registry. |
Source code in src/agentprobe/plugins/manager.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
__init__(entry_point_group='agentprobe.plugins')
¶
Initialize the plugin manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entry_point_group
|
str
|
Entry point group for plugin discovery. |
'agentprobe.plugins'
|
Source code in src/agentprobe/plugins/manager.py
load_plugins(directories=None, classes=None)
¶
Load and register plugins from all sources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directories
|
list[str] | None
|
Additional directories to scan. |
None
|
classes
|
list[type[PluginBase]] | None
|
Direct class references to load. |
None
|
Returns:
| Type | Description |
|---|---|
list[PluginBase]
|
A list of all loaded and registered plugins. |
Source code in src/agentprobe/plugins/manager.py
unload_all()
¶
Unload all plugins, calling on_unload for each.
Source code in src/agentprobe/plugins/manager.py
dispatch_test_start(test_name, **kwargs)
¶
Dispatch on_test_start to all registered plugins.
Errors from individual plugins are logged but do not propagate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
test_name
|
str
|
Name of the test starting. |
required |
**kwargs
|
Any
|
Additional context. |
{}
|
Source code in src/agentprobe/plugins/manager.py
dispatch_test_end(test_name, **kwargs)
¶
Dispatch on_test_end to all registered plugins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
test_name
|
str
|
Name of the test ending. |
required |
**kwargs
|
Any
|
Additional context. |
{}
|
Source code in src/agentprobe/plugins/manager.py
dispatch_suite_start(**kwargs)
¶
Dispatch on_suite_start to all registered plugins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional context. |
{}
|
Source code in src/agentprobe/plugins/manager.py
dispatch_suite_end(**kwargs)
¶
Dispatch on_suite_end to all registered plugins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional context. |
{}
|
Source code in src/agentprobe/plugins/manager.py
get_evaluators()
¶
Collect evaluators from all EvaluatorPlugin instances.
Returns:
| Type | Description |
|---|---|
list[EvaluatorProtocol]
|
A list of evaluator instances. |
Source code in src/agentprobe/plugins/manager.py
get_adapters()
¶
Collect adapters from all AdapterPlugin instances.
Returns:
| Type | Description |
|---|---|
list[AdapterProtocol]
|
A list of adapter instances. |
Source code in src/agentprobe/plugins/manager.py
get_reporters()
¶
Collect reporters from all ReporterPlugin instances.
Returns:
| Type | Description |
|---|---|
list[ReporterProtocol]
|
A list of reporter instances. |
Source code in src/agentprobe/plugins/manager.py
get_storage_backends()
¶
Collect storage backends from all StoragePlugin instances.
Returns:
| Type | Description |
|---|---|
list[StorageProtocol]
|
A list of storage backend instances. |