Skip to content

Commit 3814b7e

Browse files
committed
Added type hints existence validation to make error message when missing more explicit
1 parent e582072 commit 3814b7e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

python/packages/autogen-core/src/autogen_core/tools/_function_tool.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import functools
33
import warnings
4+
import typing
45
from textwrap import dedent
56
from typing import Any, Callable, Sequence
67

@@ -87,6 +88,12 @@ def __init__(
8788
) -> None:
8889
self._func = func
8990
self._global_imports = global_imports
91+
92+
# Validate type hints exist
93+
hints = typing.get_type_hints(func)
94+
if not hints:
95+
raise TypeError(f"Function '{func.__name__}' has no type hints. All parameters must be annotated.")
96+
9097
signature = get_typed_signature(func)
9198
func_name = name or func.__name__
9299
args_model = args_base_model_from_signature(func_name + "args", signature)

0 commit comments

Comments
 (0)