Repository: phidatahq/phidata
File: libs/agno/agno/tools/decorator.py (Python)

Code before:
                return True
    except (AttributeError, TypeError):
        pass

    return False


@overload
def tool() -> Callable[[F], Function]: ...


@overload
def tool(
    *,
    name: Optional[str] = None,
    description: Optional[str] = None,
    strict: Optional[bool] = None,
    instructions: Optional[str] = None,
    add_instructions: bool = True,
    show_result: Optional[bool] = None,
    stop_after_tool_call: Optional[bool] = None,
    requires_confirmation: Optional[bool] = None,
    requires_user_input: Optional[bool] = None,
    user_input_fields: Optional[List[str]] = None,
    external_execution: Optional[bool] = None,
    silent: Optional[bool] = None,
    pre_hook: Optional[Callable] = None,
    post_hook: Optional[Callable] = None,
    tool_hooks: Optional[List[Callable]] = None,
    cache_results: bool = False,
    cache_dir: Optional[str] = None,
    cache_ttl: int = 3600,
) -> Callable[[F], Function]: ...


@overload
def tool(func: F) -> Function: ...


def tool(*args, **kwargs) -> Union[Function, Callable[[F], Function]]:
    """Decorator to convert a function into a Function that can be used by an agent.

    Args:
        name: Optional[str] - Override for the function name
        description: Optional[str] - Override for the function description
        strict: Optional[bool] - Flag for strict parameter checking
        instructions: Optional[str] - Instructions for using the tool
        add_instructions: bool - If True, add instructions to the system message
        show_result: Optional[bool] - If True, shows the result after function call
        stop_after_tool_call: Optional[bool] - If True, the agent will stop after the function call.
        requires_confirmation: Optional[bool] - If True, the function will require user confirmation before execution

Review comment (suggestion):
also just thinking if the `silent` flag name is a bit misleading here? as its only supposed to be for this particular case along with external execution right, but just having silent seems people might start using it to expecting in other ways.. wdyt

Code after:
                return True
    except (AttributeError, TypeError):
        pass

    return False


@overload
def tool() -> Callable[[F], Function]: ...


@overload
def tool(
    *,
    name: Optional[str] = None,
    description: Optional[str] = None,
    strict: Optional[bool] = None,
    instructions: Optional[str] = None,
    add_instructions: bool = True,
    show_result: Optional[bool] = None,
    stop_after_tool_call: Optional[bool] = None,
    requires_confirmation: Optional[bool] = None,
    requires_user_input: Optional[bool] = None,
    user_input_fields: Optional[List[str]] = None,
    external_execution: Optional[bool] = None,
    external_execution_silent: Optional[bool] = None,
    pre_hook: Optional[Callable] = None,
    post_hook: Optional[Callable] = None,
    tool_hooks: Optional[List[Callable]] = None,
    cache_results: bool = False,
    cache_dir: Optional[str] = None,
    cache_ttl: int = 3600,
) -> Callable[[F], Function]: ...


@overload
def tool(func: F) -> Function: ...


def tool(*args, **kwargs) -> Union[Function, Callable[[F], Function]]:
    """Decorator to convert a function into a Function that can be used by an agent.

    Args:
        name: Optional[str] - Override for the function name
        description: Optional[str] - Override for the function description
        strict: Optional[bool] - Flag for strict parameter checking
        instructions: Optional[str] - Instructions for using the tool
        add_instructions: bool - If True, add instructions to the system message
        show_result: Optional[bool] - If True, shows the result after function call
        stop_after_tool_call: Optional[bool] - If True, the agent will stop after the function call.
        requires_confirmation: Optional[bool] - If True, the function will require user confirmation before execution