Skip to content

Commit e89b648

Browse files
author
Murat Kaan Meral
committed
fix: make composition keywords private
1 parent dd80924 commit e89b648

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/strands/tools/registry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from ..experimental.tools import ToolProvider
2424
from ..types.tools import AgentTool, ToolSpec
2525
from .loader import load_tool_from_string, load_tools_from_module
26-
from .tools import COMPOSITION_KEYWORDS, PythonAgentTool, normalize_schema, normalize_tool_spec
26+
from .tools import _COMPOSITION_KEYWORDS, PythonAgentTool, normalize_schema, normalize_tool_spec
2727

2828
logger = logging.getLogger(__name__)
2929

@@ -602,7 +602,7 @@ def validate_tool_spec(self, tool_spec: ToolSpec) -> None:
602602
if "$ref" in prop_def:
603603
continue
604604

605-
has_composition = any(kw in prop_def for kw in COMPOSITION_KEYWORDS)
605+
has_composition = any(kw in prop_def for kw in _COMPOSITION_KEYWORDS)
606606
if "type" not in prop_def and not has_composition:
607607
prop_def["type"] = "string"
608608
if "description" not in prop_def:

src/strands/tools/tools.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717

1818
logger = logging.getLogger(__name__)
1919

20-
# JSON Schema composition keywords that define type constraints.
21-
# Properties with these should not get a default type: "string" added.
22-
COMPOSITION_KEYWORDS = ("anyOf", "oneOf", "allOf", "not")
20+
_COMPOSITION_KEYWORDS = ("anyOf", "oneOf", "allOf", "not")
21+
"""JSON Schema composition keywords that define type constraints.
22+
23+
Properties with these should not get a default type: "string" added.
24+
"""
2325

2426

2527
class InvalidToolUseNameException(Exception):
@@ -92,7 +94,7 @@ def _normalize_property(prop_name: str, prop_def: Any) -> dict[str, Any]:
9294
if "$ref" in normalized_prop:
9395
return normalized_prop
9496

95-
has_composition = any(kw in normalized_prop for kw in COMPOSITION_KEYWORDS)
97+
has_composition = any(kw in normalized_prop for kw in _COMPOSITION_KEYWORDS)
9698
if not has_composition:
9799
normalized_prop.setdefault("type", "string")
98100
normalized_prop.setdefault("description", f"Property {prop_name}")

0 commit comments

Comments
 (0)