From a626d7cf18e1a8e2fac47158291ee5176cf80bd9 Mon Sep 17 00:00:00 2001 From: Leonardo Pinheiro Date: Sun, 27 Oct 2024 15:13:52 +1000 Subject: [PATCH] replace assertion with valueerror (#3974) Co-authored-by: Leonardo Pinheiro --- .../src/autogen_core/components/tools/_function_tool.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/packages/autogen-core/src/autogen_core/components/tools/_function_tool.py b/python/packages/autogen-core/src/autogen_core/components/tools/_function_tool.py index 131cea748358..e537deeba9c6 100644 --- a/python/packages/autogen-core/src/autogen_core/components/tools/_function_tool.py +++ b/python/packages/autogen-core/src/autogen_core/components/tools/_function_tool.py @@ -46,5 +46,6 @@ async def run(self, args: BaseModel, cancellation_token: CancellationToken) -> A cancellation_token.link_future(future) result = await future - assert isinstance(result, self.return_type()) + if not isinstance(result, self.return_type()): + raise ValueError(f"Expected return type {self.return_type()}, got {type(result)}") return result