File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
libs/naas-abi-core/naas_abi_core/services/agent Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -1059,6 +1059,7 @@ def call_tools(self, state: ABIAgentState) -> list[Command]:
10591059
10601060 # Initialize the results list.
10611061 results : list [Command ] = []
1062+ had_tool_error : bool = False
10621063
10631064 # Initialize the called tools list.
10641065 called_tools : list [BaseTool ] = []
@@ -1130,13 +1131,15 @@ def call_tools(self, state: ABIAgentState) -> list[Command]:
11301131 )
11311132 except Exception as e :
11321133 logger .error (f"🚨 Tool call { tool_name } failed: { e } " )
1134+ had_tool_error = True
1135+ called_tools .append (tool_ )
11331136 results .append (
11341137 Command (
1135- goto = "__end__" ,
11361138 update = {
11371139 "messages" : [
11381140 ToolMessage (
11391141 content = f"Tool call { tool_name } failed: { str (e )} " ,
1142+ name = tool_name ,
11401143 tool_call_id = tool_call ["id" ],
11411144 )
11421145 ]
@@ -1165,7 +1168,10 @@ def call_tools(self, state: ABIAgentState) -> list[Command]:
11651168 and last_tool_reponse .name is not None
11661169 and not last_tool_reponse .name .startswith ("transfer_to_" )
11671170 ):
1168- if return_direct is False :
1171+ if had_tool_error :
1172+ logger .debug ("⏩ Calling model to interpret the tool error response." )
1173+ results .append (Command (goto = "call_model" ))
1174+ elif return_direct is False :
11691175 logger .debug ("⏩ Calling model to interpret the tool response." )
11701176 results .append (Command (goto = "call_model" ))
11711177 else :
You can’t perform that action at this time.
0 commit comments