3131from astrbot .core .platform .message_session import MessageSession
3232from astrbot .core .provider .entites import ProviderRequest
3333from astrbot .core .provider .register import llm_tools
34+ from astrbot .core .subagent_manager import SubAgentManager
3435from astrbot .core .tools .computer_tools import (
3536 CuaKeyboardTypeTool ,
3637 CuaMouseClickTool ,
@@ -823,8 +824,6 @@ async def _execute_mcp(
823824 def _load_subagent_history (
824825 umo : str , tool : HandoffTool
825826 ) -> tuple [list [Message ], str ]:
826- from astrbot .core .subagent_manager import SubAgentManager
827-
828827 agent_name = getattr (tool .agent , "name" , None )
829828 subagent_history = []
830829 if agent_name :
@@ -871,8 +870,6 @@ def _build_subagent_system_prompt(
871870 f"# Role\n Your name is { agent_name } (used for tool calling)\n { base } \n "
872871 )
873872 if agent_name :
874- from astrbot .core .subagent_manager import SubAgentManager
875-
876873 runtime = prov_settings .get ("computer_use_runtime" , "local" )
877874 static_subagent_prompt = SubAgentManager .build_static_subagent_prompts (
878875 umo , agent_name
@@ -889,8 +886,6 @@ def _save_subagent_history(
889886 umo : str , runner_messages : list [Message ], agent_name : str
890887 ) -> None :
891888 if agent_name and runner_messages :
892- from astrbot .core .subagent_manager import SubAgentManager
893-
894889 # 仅在历史功能启用时保存历史
895890 if SubAgentManager .is_history_enabled ():
896891 SubAgentManager .update_subagent_history (
@@ -908,8 +903,6 @@ def _register_subagent_task(umo: str, agent_name: str | None) -> str | None:
908903 if not agent_name :
909904 return None
910905 try :
911- from astrbot .core .subagent_manager import SubAgentManager
912-
913906 session = SubAgentManager .get_session (umo )
914907 if session and (agent_name in session .subagents ):
915908 subagent_task_id = SubAgentManager .create_pending_subagent_task (
@@ -967,8 +960,6 @@ def _build_background_submission_message(
967960 @staticmethod
968961 def _get_subagent_execution_timeout () -> float :
969962 try :
970- from astrbot .core .subagent_manager import SubAgentManager
971-
972963 return SubAgentManager .get_execution_timeout ()
973964 except Exception :
974965 return - 1
@@ -978,8 +969,6 @@ def _handle_subagent_timeout(
978969 umo : str ,
979970 agent_name : str ,
980971 ) -> None :
981- from astrbot .core .subagent_manager import SubAgentManager
982-
983972 SubAgentManager .set_subagent_status (
984973 session_id = umo ,
985974 agent_name = agent_name ,
@@ -988,8 +977,6 @@ def _handle_subagent_timeout(
988977
989978 @staticmethod
990979 def _is_managed_subagent (umo : str , agent_name : str | None ) -> bool :
991- from astrbot .core .subagent_manager import SubAgentManager
992-
993980 if not agent_name :
994981 return False
995982 session = SubAgentManager .get_session (umo )
@@ -1011,8 +998,6 @@ async def _handle_subagent_background_result(
1011998 tool : HandoffTool ,
1012999 tool_args : dict ,
10131000 ) -> None :
1014- from astrbot .core .subagent_manager import SubAgentManager
1015-
10161001 success = error_text is None
10171002 status = "COMPLETED" if success else "FAILED"
10181003 SubAgentManager .set_subagent_status (
0 commit comments