Skip to content

Commit c0d24d3

Browse files
authored
Fix toolcall error (#40548)
* Fix toolcall error * Fixed lint
1 parent 77ae5d0 commit c0d24d3

File tree

1 file changed

+3
-4
lines changed
  • sdk/ai/azure-ai-projects/azure/ai/projects/models

1 file changed

+3
-4
lines changed

sdk/ai/azure-ai-projects/azure/ai/projects/models/_patch.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ def execute(self, tool_call: RequiredFunctionToolCall) -> Any:
734734
try:
735735
function, parsed_arguments = self._get_func_and_args(tool_call)
736736
return function(**parsed_arguments) if parsed_arguments else function()
737-
except TypeError as e:
737+
except Exception as e: # pylint: disable=broad-exception-caught
738738
error_message = f"Error executing function '{tool_call.function.name}': {e}"
739739
logging.error(error_message)
740740
# Return error message as JSON string back to agent in order to make possible self
@@ -745,13 +745,12 @@ def execute(self, tool_call: RequiredFunctionToolCall) -> Any:
745745
class AsyncFunctionTool(BaseFunctionTool):
746746

747747
async def execute(self, tool_call: RequiredFunctionToolCall) -> Any: # pylint: disable=invalid-overridden-method
748-
function, parsed_arguments = self._get_func_and_args(tool_call)
749-
750748
try:
749+
function, parsed_arguments = self._get_func_and_args(tool_call)
751750
if inspect.iscoroutinefunction(function):
752751
return await function(**parsed_arguments) if parsed_arguments else await function()
753752
return function(**parsed_arguments) if parsed_arguments else function()
754-
except TypeError as e:
753+
except Exception as e: # pylint: disable=broad-exception-caught
755754
error_message = f"Error executing function '{tool_call.function.name}': {e}"
756755
logging.error(error_message)
757756
# Return error message as JSON string back to agent in order to make possible self correction

0 commit comments

Comments
 (0)