Skip to content

ToolHandler

Base classes

Name Children Inherits
Protocol
typing
Base class for protocol classes.

⋔ Inheritance diagram

graph TD
  1070717991["types.ToolHandler"]
  1073422405["typing.Protocol"]
  3481597255["typing.Generic"]
  2751680898["builtins.object"]
  1073422405 --> 1070717991
  3481597255 --> 1073422405
  2751680898 --> 3481597255

🛈 DocStrings

Bases: Protocol

Protocol for user-provided tool handler.

Source code in src/schemez/tool_executor/types.py
class ToolHandler(Protocol):
    """Protocol for user-provided tool handler."""

    async def __call__(self, method_name: str, input_props: BaseModel) -> str:
        """Process a tool call.

        Args:
            method_name: Name of the tool being called (e.g., "get_weather")
            input_props: Validated input model instance

        Returns:
            String result from the tool execution

        Raises:
            Exception: If tool execution fails
        """
        ...

__call__ async

__call__(method_name: str, input_props: BaseModel) -> str

Process a tool call.

Parameters:

Name Type Description Default
method_name str

Name of the tool being called (e.g., "get_weather")

required
input_props BaseModel

Validated input model instance

required

Returns:

Type Description
str

String result from the tool execution

Raises:

Type Description
Exception

If tool execution fails

Source code in src/schemez/tool_executor/types.py
async def __call__(self, method_name: str, input_props: BaseModel) -> str:
    """Process a tool call.

    Args:
        method_name: Name of the tool being called (e.g., "get_weather")
        input_props: Validated input model instance

    Returns:
        String result from the tool execution

    Raises:
        Exception: If tool execution fails
    """
    ...

:fa-brands-github: Show source on GitHub