Skip to content

strands.tools.watcher

Tool watcher for hot reloading tools during development.

This module provides functionality to watch tool directories for changes and automatically reload tools when they are modified.

class ToolWatcher()

Defined in: src/strands/tools/watcher.py:19

Watches tool directories for changes and reloads tools when they are modified.

def __init__(tool_registry: ToolRegistry) -> None

Defined in: src/strands/tools/watcher.py:32

Initialize a tool watcher for the given tool registry.

Arguments:

  • tool_registry - The tool registry to report changes.
class ToolChangeHandler(FileSystemEventHandler)

Defined in: src/strands/tools/watcher.py:41

Handler for tool file changes.

def __init__(tool_registry: ToolRegistry) -> None

Defined in: src/strands/tools/watcher.py:44

Initialize a tool change handler.

Arguments:

  • tool_registry - The tool registry to update when tools change.
def on_modified(event: Any) -> None

Defined in: src/strands/tools/watcher.py:52

Reload tool if file modification detected.

Arguments:

  • event - The file system event that triggered this handler.
class MasterChangeHandler(FileSystemEventHandler)

Defined in: src/strands/tools/watcher.py:69

Master handler that delegates to all registered handlers.

def __init__(dir_path: str) -> None

Defined in: src/strands/tools/watcher.py:72

Initialize a master change handler for a specific directory.

Arguments:

  • dir_path - The directory path to watch.
def on_modified(event: Any) -> None

Defined in: src/strands/tools/watcher.py:80

Delegate file modification events to all registered handlers.

Arguments:

  • event - The file system event that triggered this handler.
def start() -> None

Defined in: src/strands/tools/watcher.py:98

Start watching all tools directories for changes.