@@ -36,7 +36,10 @@ def reset_configuration() -> None:
3636 # Clear backends registry if it exists
3737 try :
3838 import praisonaiui .backends as backends
39- backends .clear_backends ()
39+ if hasattr (backends , 'clear_backends' ):
40+ backends .clear_backends ()
41+ elif hasattr (backends , '_backends' ):
42+ backends ._backends .clear ()
4043 except (ImportError , AttributeError ):
4144 pass
4245 except ImportError :
@@ -135,42 +138,33 @@ def configure_host(
135138 from praisonaiui .providers import PraisonAIProvider
136139 from praisonaiui .server import set_provider
137140
138- # Check if we're in a test environment where the provider will be overridden
139- is_test_env = False
140- try :
141- import praisonaiui .server as srv
142- # If set_provider has been monkeypatched (common test pattern), defer provider setup
143- if hasattr (set_provider , '__name__' ) and set_provider .__name__ == '<lambda>' :
144- is_test_env = True
145- except :
146- pass
147-
148- if not is_test_env :
149- kwargs = dict (agent_kwargs or {})
150- if agents :
151- set_provider (PraisonAIProvider (agents = list (agents ), ** kwargs ))
152- else :
153- # Load context files if specified
154- instructions = kwargs .pop ("instructions" , "You are a helpful assistant." )
155- if context_paths :
156- try :
157- from praisonai .integration .context_files import load_context_files
158- context = load_context_files (list (context_paths ))
159- if context :
160- instructions = f"{ instructions } \n \n Context:\n { context } "
161- except ImportError :
162- pass # Context files helper is optional
163-
164- set_provider (
165- PraisonAIProvider (
166- name = kwargs .pop ("name" , "PraisonAI" ),
167- instructions = instructions ,
168- llm = kwargs .pop (
169- "llm" , os .getenv ("PRAISONAI_MODEL" , "gpt-4o-mini" )
170- ),
171- ** kwargs ,
172- )
141+ # Always proceed with provider setup unless explicitly skipped by legacy mode
142+ # Tests that need to override providers should do so after configure_host() completes
143+ kwargs = dict (agent_kwargs or {})
144+ if agents :
145+ set_provider (PraisonAIProvider (agents = list (agents ), ** kwargs ))
146+ else :
147+ # Load context files if specified
148+ instructions = kwargs .pop ("instructions" , "You are a helpful assistant." )
149+ if context_paths :
150+ try :
151+ from praisonai .integration .context_files import load_context_files
152+ context = load_context_files (list (context_paths ))
153+ if context :
154+ instructions = f"{ instructions } \n \n Context:\n { context } "
155+ except ImportError :
156+ pass # Context files helper is optional
157+
158+ set_provider (
159+ PraisonAIProvider (
160+ name = kwargs .pop ("name" , "PraisonAI" ),
161+ instructions = instructions ,
162+ llm = kwargs .pop (
163+ "llm" , os .getenv ("PRAISONAI_MODEL" , "gpt-4o-mini" )
164+ ),
165+ ** kwargs ,
173166 )
167+ )
174168 setup_bridges ()
175169
176170 # Register L3 dashboard pages
0 commit comments