Skip to content

Commit ecd9eab

Browse files
authored
feat: add supports_hot_reload property to PythonAgentTool (#928)
1 parent 04669d8 commit ecd9eab

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

src/strands/tools/tools.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ def tool_spec(self) -> ToolSpec:
189189
"""
190190
return self._tool_spec
191191

192+
@property
193+
def supports_hot_reload(self) -> bool:
194+
"""Check if this tool supports automatic reloading when modified.
195+
196+
Returns:
197+
Always true for function-based tools.
198+
"""
199+
return True
200+
192201
@property
193202
def tool_type(self) -> str:
194203
"""Identifies this as a Python-based tool implementation.

tests/strands/tools/test_registry.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,16 @@ def function() -> str:
124124

125125
def test_register_tool_duplicate_name_without_hot_reload():
126126
"""Test that registering a tool with duplicate name raises ValueError when hot reload is not supported."""
127-
tool_1 = PythonAgentTool(tool_name="duplicate_tool", tool_spec=MagicMock(), tool_func=lambda: None)
128-
tool_2 = PythonAgentTool(tool_name="duplicate_tool", tool_spec=MagicMock(), tool_func=lambda: None)
127+
# Create mock tools that don't support hot reload
128+
tool_1 = MagicMock()
129+
tool_1.tool_name = "duplicate_tool"
130+
tool_1.supports_hot_reload = False
131+
tool_1.is_dynamic = False
132+
133+
tool_2 = MagicMock()
134+
tool_2.tool_name = "duplicate_tool"
135+
tool_2.supports_hot_reload = False
136+
tool_2.is_dynamic = False
129137

130138
tool_registry = ToolRegistry()
131139
tool_registry.register_tool(tool_1)

tests/strands/tools/test_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ def test_tool_type(identity_tool):
487487

488488
@pytest.mark.parametrize("identity_tool", ["identity_invoke", "identity_invoke_async"], indirect=True)
489489
def test_supports_hot_reload(identity_tool):
490-
assert not identity_tool.supports_hot_reload
490+
assert identity_tool.supports_hot_reload
491491

492492

493493
@pytest.mark.parametrize("identity_tool", ["identity_invoke", "identity_invoke_async"], indirect=True)

0 commit comments

Comments
 (0)