Skip to content

Agent Zero AI framework

Remove redundant provider reload call from plugin change handler

frdel36f26c1e2ce8
diff --git a/helpers/plugins.py b/helpers/plugins.py
index 2daf21682..fe67e6fe6 100644
--- a/helpers/plugins.py
+++ b/helpers/plugins.py
@@ -79,8 +79,6 @@ class PluginListItem(BaseModel):
def after_plugin_change(plugin_names: list[str] | None = None):
clear_plugin_cache()
- from helpers.providers import reload_providers
- reload_providers()
send_frontend_reload_notification(plugin_names)
diff --git a/helpers/providers.py b/helpers/providers.py
index 3c04358cf..35888b73f 100644
--- a/helpers/providers.py
+++ b/helpers/providers.py
@@ -1,28 +1,33 @@
import yaml
-from helpers import files
+from helpers import files, cache
from typing import List, Dict, Optional, TypedDict, Literal
ModelType = Literal["chat", "embedding"]
+PROVIDER_MANAGER_CACHE_AREA = "model_providers(plugins)"
+PROVIDER_MANAGER_CACHE_KEY = "manager"
+
# Type alias for UI option items
class FieldOption(TypedDict):
value: str
label: str
class ProviderManager:
- _instance = None
_raw: Optional[Dict[str, List[Dict[str, str]]]] = None # full provider data
_options: Optional[Dict[str, List[FieldOption]]] = None # UI-friendly list
@classmethod
def get_instance(cls):
- if cls._instance is None:
- cls._instance = cls()
- return cls._instance
+ instance = cache.get(PROVIDER_MANAGER_CACHE_AREA, PROVIDER_MANAGER_CACHE_KEY)
+ if instance is None:
+ instance = cls()
+ cache.add(PROVIDER_MANAGER_CACHE_AREA, PROVIDER_MANAGER_CACHE_KEY, instance)
+ return instance
@classmethod
def reload(cls):
"""Force reload of all provider configs (call after plugin changes)."""
+ cache.remove(PROVIDER_MANAGER_CACHE_AREA, PROVIDER_MANAGER_CACHE_KEY)
inst = cls.get_instance()
inst._load_providers()