Skip to content

Commit 38c4f78

Browse files
authored
tools - stop filter $defs (#294)
1 parent 5a69a12 commit 38c4f78

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/strands/tools/decorator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def _clean_pydantic_schema(self, schema: Dict[str, Any]) -> None:
195195
schema: The Pydantic-generated JSON schema to clean up (modified in place).
196196
"""
197197
# Remove Pydantic metadata
198-
keys_to_remove = ["title", "$defs", "additionalProperties"]
198+
keys_to_remove = ["title", "additionalProperties"]
199199
for key in keys_to_remove:
200200
if key in schema:
201201
del schema[key]

src/strands/tools/registry.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,10 @@ def validate_tool_spec(self, tool_spec: ToolSpec) -> None:
538538
}
539539
continue
540540

541+
# It is expected that type and description are already included in referenced $def.
542+
if "$ref" in prop_def:
543+
continue
544+
541545
if "type" not in prop_def:
542546
prop_def["type"] = "string"
543547
if "description" not in prop_def:

src/strands/tools/tools.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ def _normalize_property(prop_name: str, prop_def: Any) -> Dict[str, Any]:
8181

8282
# Copy existing property, ensuring defaults
8383
normalized_prop = prop_def.copy()
84+
85+
# It is expected that type and description are already included in referenced $def.
86+
if "$ref" in normalized_prop:
87+
return normalized_prop
88+
8489
normalized_prop.setdefault("type", "string")
8590
normalized_prop.setdefault("description", f"Property {prop_name}")
8691
return normalized_prop

0 commit comments

Comments
 (0)