Skip to content

Commit 96ed97c

Browse files
committed
feat(tools): add support for string descriptions in Annotated
1 parent c8818d1 commit 96ed97c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/strands/tools/decorator.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def my_tool(param1: str, param2: int = 42) -> dict:
5757
cast,
5858
get_args,
5959
get_origin,
60-
get_type_hints,
6160
overload,
6261
)
6362

@@ -101,7 +100,6 @@ def __init__(self, func: Callable[..., Any], context_param: str | None = None) -
101100
"""
102101
self.func = func
103102
self.signature = inspect.signature(func)
104-
self.type_hints = get_type_hints(func, include_extras=True)
105103
self._context_param = context_param
106104

107105
self._validate_signature()
@@ -201,8 +199,9 @@ def _create_input_model(self) -> Type[BaseModel]:
201199
if self._is_special_parameter(name):
202200
continue
203201

204-
# Fallback to Any for params without type hints to prevent Pydantic errors
205-
param_type = self.type_hints.get(name, param.annotation)
202+
# Use param.annotation directly to get the raw type hint. Using get_type_hints()
203+
# can cause inconsistent behavior across Python versions for complex Annotated types.
204+
param_type = param.annotation
206205
if param_type is inspect.Parameter.empty:
207206
param_type = Any
208207

0 commit comments

Comments
 (0)