Decorator to check whether a tool stream has been defined before execution
    :return: the decorator

def check_tool_defined(func):
    """
    Decorator to check whether a tool stream has been defined before execution
    :return: the decorator
    """
    def func_wrapper(*args):
        self = args[0]
        # Deferred import to avoid circular dependency
        from ..channels import ToolChannel
        if isinstance(self.channel, ToolChannel) and not self.defined:
            raise RuntimeError("Tool not yet defined")
        return func(*args)
    return func_wrapper