diff --git a/python/composio/tools/base/runtime.py b/python/composio/tools/base/runtime.py index 88b36c5c43..53aea634a1 100644 --- a/python/composio/tools/base/runtime.py +++ b/python/composio/tools/base/runtime.py @@ -262,7 +262,7 @@ def _get_auth_params(app: str, entity_id: str) -> t.Optional[t.Dict]: return None -def _build_executable_from_args( +def _build_executable_from_args( # pylint: disable=too-many-statements f: t.Callable, app: str, ) -> t.Tuple[t.Callable, t.Type[BaseModel], t.Type[BaseModel], bool,]: @@ -291,6 +291,11 @@ def _build_executable_from_args( } shell_argument = None auth_params = False + if "return" not in argspec.annotations: + raise InvalidRuntimeAction( + f"Please add return type on runtime action `{f.__name__}`" + ) + for arg, annot in argspec.annotations.items(): if annot is Shell: shell_argument = arg @@ -323,7 +328,6 @@ def _build_executable_from_args( description = paramdesc[arg] default = defaults.get(arg, ...) - if arg == "return": if returns is not None: arg, _ = returns diff --git a/python/tests/test_tools/test_base/test_runtime.py b/python/tests/test_tools/test_base/test_runtime.py index 6019f102fd..5f704cf72a 100644 --- a/python/tests/test_tools/test_base/test_runtime.py +++ b/python/tests/test_tools/test_base/test_runtime.py @@ -113,6 +113,22 @@ def square(number: int) -> int: return number**2 +def test_missing_return_type() -> None: + with pytest.raises( + InvalidRuntimeAction, + match="Please add return type on runtime action `square`", + ): + + @action(toolname="math") + def square(number: int): + """ + Calculate square of a number + + :return result: Square of number + """ + return number**2 + + def test_tool_namespace() -> None: """Test to make sure two runtime actions can be defined using one tool name."""