Move subagents import to function scope to avoid circular import

Defer `from helpers import subagents` to function scope in get_webui_extensions and _get_extension_classes to prevent circular import issues. Remove module-level subagents import.

frdel committed Mar 26, 2026 at 12:39 UTC f69147aee900cb0754af00c9aa1ba1f87a78d52a
1 file changed +6 -2
helpers/extension.py
+6 -2
@@ -1,7 +1,7 @@
1 from abc import abstractmethod
2 from typing import Any, Awaitable, Type, cast
3 from helpers import modules, files
4 -from helpers import cache, subagents
4 +from helpers import cache
5 from typing import TYPE_CHECKING
6 from functools import wraps
7 import inspect
@@ -253,6 +253,8 @@ def call_extensions_sync(extension_point: str, agent: "Agent|None" = None, **kwa
253 def get_webui_extensions(
254 agent: "Agent | None", extension_point: str, filters: list[str] | None = None
255 ):
256 + from helpers import subagents
257 +
258 entries: list[str] = []
259 effective_filters = filters or ["*"]
260
@@ -280,6 +282,8 @@ def get_webui_extensions(
282 def _get_extension_classes(
283 extension_point: str, agent: "Agent|None" = None, **kwargs
284 ) -> list[Type[Extension]]:
285 + from helpers import subagents
286 +
287 cache_key = cache.determine_cache_key(agent, extension_point)
288 cached = cache.get(_CLASSES_CACHE_AREA, cache_key)
289 if cached is not None:
@@ -356,4 +360,4 @@ def register_extensions_watchdogs():
360 ],
361 patterns=[f"*/{files.EXTENSIONS_DIR}/**/*"],
362 handler=extensions_changed,
359 - )
\ No newline at end of file
363 + )