Finding
PluginManager.plugins and PluginManager.plugin_handlers are defined as class-level mutable lists, while PluginManager.__init__ does not assign fresh instance lists. Creating multiple managers in the same Python process causes plugin state and handlers to leak between instances.
Why this matters
Tests or embedded/runtime scenarios that instantiate more than one PluginManager can observe stale plugins from a previous manager. This can produce incorrect plugin discovery, event emission, shutdown, or installation behavior.
Reproduction locked in tests
On the test-build branch:
uv run pytest tests/runtime/plugin/test_manager.py::test_plugin_manager_instances_should_not_share_plugin_state -q
The test is marked xfail(strict=True) to document the current bug without modifying SDK source in the test-build branch.
Expected behavior
Each PluginManager instance should own independent plugins and plugin_handlers lists, normally by initializing them in __init__.
Finding
PluginManager.pluginsandPluginManager.plugin_handlersare defined as class-level mutable lists, whilePluginManager.__init__does not assign fresh instance lists. Creating multiple managers in the same Python process causes plugin state and handlers to leak between instances.Why this matters
Tests or embedded/runtime scenarios that instantiate more than one
PluginManagercan observe stale plugins from a previous manager. This can produce incorrect plugin discovery, event emission, shutdown, or installation behavior.Reproduction locked in tests
On the
test-buildbranch:The test is marked
xfail(strict=True)to document the current bug without modifying SDK source in the test-build branch.Expected behavior
Each
PluginManagerinstance should own independentpluginsandplugin_handlerslists, normally by initializing them in__init__.