Agent Zero AI framework

Remove redundant provider reload call from plugin change handler

The provider manager now uses the plugin cache system and automatically reloads when plugins change, making the explicit reload_providers() call unnecessary.

frdel committed Mar 12, 2026 at 07:31 UTC 36f26c1e2ce8012ed31e2016b3e99477e9a7dfc8
2 files changed +10 -7
helpers/plugins.py
-2
@@ -79,8 +79,6 @@ class PluginListItem(BaseModel):
79
80 def after_plugin_change(plugin_names: list[str] | None = None):
81 clear_plugin_cache()
82 - from helpers.providers import reload_providers
83 - reload_providers()
82 send_frontend_reload_notification(plugin_names)
83
84
helpers/providers.py
+10 -5
@@ -1,28 +1,33 @@
1 import yaml
2 -from helpers import files
2 +from helpers import files, cache
3 from typing import List, Dict, Optional, TypedDict, Literal
4
5 ModelType = Literal["chat", "embedding"]
6
7 +PROVIDER_MANAGER_CACHE_AREA = "model_providers(plugins)"
8 +PROVIDER_MANAGER_CACHE_KEY = "manager"
9 +
10 # Type alias for UI option items
11 class FieldOption(TypedDict):
12 value: str
13 label: str
14
15 class ProviderManager:
13 - _instance = None
16 _raw: Optional[Dict[str, List[Dict[str, str]]]] = None # full provider data
17 _options: Optional[Dict[str, List[FieldOption]]] = None # UI-friendly list
18
19 @classmethod
20 def get_instance(cls):
19 - if cls._instance is None:
20 - cls._instance = cls()
21 - return cls._instance
21 + instance = cache.get(PROVIDER_MANAGER_CACHE_AREA, PROVIDER_MANAGER_CACHE_KEY)
22 + if instance is None:
23 + instance = cls()
24 + cache.add(PROVIDER_MANAGER_CACHE_AREA, PROVIDER_MANAGER_CACHE_KEY, instance)
25 + return instance
26
27 @classmethod
28 def reload(cls):
29 """Force reload of all provider configs (call after plugin changes)."""
30 + cache.remove(PROVIDER_MANAGER_CACHE_AREA, PROVIDER_MANAGER_CACHE_KEY)
31 inst = cls.get_instance()
32 inst._load_providers()
33