@@ -674,20 +674,28 @@ def _append_tool_call_result(tool_call_id: str, content: str) -> None:
674674 return
675675
676676 # First check if it's a dynamically created subagent tool
677- session_id = getattr (self .run_context .context .event , "unified_msg_origin" , None )
678677 func_tool = None
679678 run_context_context = getattr (self .run_context , "context" , None )
680679 if run_context_context is not None :
681680 event = getattr (run_context_context , "event" , None )
682681 if event is not None :
682+ session_id = getattr (
683+ self .run_context .context .event , "unified_msg_origin" , None
684+ )
683685 if session_id :
684686 try :
685687 from astrbot .core .dynamic_subagent_manager import (
686688 DynamicSubAgentManager ,
687689 )
688- dynamic_handoffs = DynamicSubAgentManager .get_handoff_tools_for_session (session_id )
690+
691+ dynamic_handoffs = DynamicSubAgentManager .get_handoff_tools_for_session (
692+ session_id
693+ )
689694 for h in dynamic_handoffs :
690- if h .name == func_tool_name or f"transfer_to_{ h .name } " == func_tool_name :
695+ if (
696+ h .name == func_tool_name
697+ or f"transfer_to_{ h .name } " == func_tool_name
698+ ):
691699 func_tool = h
692700 break
693701 except Exception :
@@ -701,7 +709,9 @@ def _append_tool_call_result(tool_call_id: str, content: str) -> None:
701709 ):
702710 # in 'skills_like' mode, raw.func_tool is light schema, does not have handler
703711 # so we need to get the tool from the raw tool set
704- func_tool = self ._skill_like_raw_tool_set .get_tool (func_tool_name )
712+ func_tool = self ._skill_like_raw_tool_set .get_tool (
713+ func_tool_name
714+ )
705715 else :
706716 func_tool = req .func_tool .get_tool (func_tool_name )
707717
@@ -830,22 +840,43 @@ def _append_tool_call_result(tool_call_id: str, content: str) -> None:
830840 if len (parts ) >= 4 :
831841 new_tool_name = parts [1 ]
832842 new_tool_obj_name = parts [2 ]
833- logger .info (f"[DynamicSubAgent] Tool created: { new_tool_name } " )
843+ logger .info (
844+ f"[DynamicSubAgent] Tool created: { new_tool_name } "
845+ )
834846 # Try to add the new tool to func_tool set
835847 try :
836848 from astrbot .core .dynamic_subagent_manager import (
837849 DynamicSubAgentManager ,
838850 )
839- session_id = getattr (self .run_context .context .event , "unified_msg_origin" , None )
851+
852+ session_id = getattr (
853+ self .run_context .context .event ,
854+ "unified_msg_origin" ,
855+ None ,
856+ )
840857 if session_id :
841- handoffs = DynamicSubAgentManager .get_handoff_tools_for_session (session_id )
858+ handoffs = DynamicSubAgentManager .get_handoff_tools_for_session (
859+ session_id
860+ )
842861 for handoff in handoffs :
843- if handoff .name == new_tool_obj_name or handoff .name == new_tool_name .replace ("transfer_to_" , "" ):
862+ if (
863+ handoff .name == new_tool_obj_name
864+ or handoff .name
865+ == new_tool_name .replace (
866+ "transfer_to_" , ""
867+ )
868+ ):
844869 if self .req .func_tool :
845- self .req .func_tool .add_tool (handoff )
846- logger .info (f"[DynamicSubAgent] Added { handoff .name } to func_tool set" )
870+ self .req .func_tool .add_tool (
871+ handoff
872+ )
873+ logger .info (
874+ f"[DynamicSubAgent] Added { handoff .name } to func_tool set"
875+ )
847876 except Exception as e :
848- logger .warning (f"[DynamicSubAgent] Failed to add dynamic tool: { e } " )
877+ logger .warning (
878+ f"[DynamicSubAgent] Failed to add dynamic tool: { e } "
879+ )
849880 _append_tool_call_result (
850881 func_tool_id ,
851882 result_content ,
0 commit comments