@@ -680,6 +680,24 @@ def _maybe_add_bq_plugin(plugins: list[BasePlugin]) -> list[BasePlugin]:
680680 )
681681 return plugins
682682
683+ def _wrap_loaded_agent (
684+ app_name : str ,
685+ agent_or_app : Any ,
686+ plugins : list [BasePlugin ],
687+ ) -> App :
688+ if app_name .startswith ("__" ):
689+ # AgentLoader validates special agents before they reach this point.
690+ return App .model_construct (
691+ name = app_name ,
692+ root_agent = agent_or_app ,
693+ plugins = plugins ,
694+ )
695+ return App (
696+ name = app_name ,
697+ root_agent = agent_or_app ,
698+ plugins = plugins ,
699+ )
700+
683701 if isinstance (agent_or_app , App ):
684702 # Combine existing plugins with extra plugins
685703 plugins = _maybe_add_bq_plugin (
@@ -689,17 +707,11 @@ def _maybe_add_bq_plugin(plugins: list[BasePlugin]) -> list[BasePlugin]:
689707 agentic_app = agent_or_app
690708 elif isinstance (agent_or_app , BaseAgent ):
691709 plugins = _maybe_add_bq_plugin (extra_plugins_instances )
692- agentic_app = App (
693- name = app_name ,
694- root_agent = agent_or_app ,
695- plugins = plugins ,
696- )
710+ agentic_app = _wrap_loaded_agent (app_name , agent_or_app , plugins )
697711 else :
698712 # BaseNode (non-agent)
699- agentic_app = App (
700- name = app_name ,
701- root_agent = agent_or_app ,
702- plugins = extra_plugins_instances ,
713+ agentic_app = _wrap_loaded_agent (
714+ app_name , agent_or_app , extra_plugins_instances
703715 )
704716
705717 # If the root agent was loaded from YAML, we treat it as being from Visual Builder
0 commit comments