Skip to content

[test-build] PluginManager shares plugin state across instances #63

@huanghuoguoguo

Description

@huanghuoguoguo

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__.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions