Skip to content

ToolRegistry

relationalai.agent.cortex.tool
ToolRegistry(tools=None)

Registry for RAI tools accessible to a Cortex agent.

Provides a unified interface for tool discovery, verbalization, explanation, and querying over a RAI model.

>>> registry = ToolRegistry()
>>> registry.add(model=model, description="Jaffle shop data")
ToolRegistry.add(
model: Optional[rai.Model] = None,
description: Optional[str] = None,
verbalizer: Optional[Verbalizer] = None,
queries: Optional[Queries] = None,
tool: Optional[Tool] = None,
) -> ToolRegistry

Add a tool to the registry.

This method supports two calling patterns:

  1. Provide a Tool instance directly via the tool parameter.
  2. Provide model + description (creates DefaultTool internally with optional verbalizer and queries).

Parameters:

  • model

    (Model, default: None) - RAI Model instance (required if tool is None).
  • description

    (str, default: None) - Human-readable tool description (required if tool is None).
  • verbalizer

    (Verbalizer, default: None) - Custom verbalizer (only used if tool is None).
  • queries

    (Queries, default: None) - Queries provider (only used if tool is None).
  • tool

    (Tool, default: None) - Pre-constructed Tool instance. If provided, other parameters are ignored.

Returns:

Examples:

>>> registry = ToolRegistry()
>>> registry.add(model=model, description="Jaffle shop")
ToolRegistry.has_tools() -> bool

Check if at least one tool is registered.

Returns:

  • bool - True if one or more tools are registered.
ToolRegistry.has_capability(capability: Capability) -> bool

Check if any tool in the registry has the specified capability.

Parameters:

  • capability

    (Capability) - The capability to check for.

Returns:

  • bool - True if any registered tool has the capability.
ToolRegistry.tool_has_capability(tool_id: int, capability: Capability) -> bool

Check if a specific tool has the specified capability.

Parameters:

  • tool_id

    (int) - The numeric tool index to check.
  • capability

    (Capability) - The capability to check for.

Returns:

  • bool - True if the tool exists and has the capability.
ToolRegistry.discover() -> dict

Discover all registered tools and their metadata.

Returns:

  • dict - Dictionary with "models" key containing a list of tool metadata including model_id, description, key_concepts, and query info.
ToolRegistry.verbalize(model_id: int) -> str

Get detailed model structure for a specific tool.

Parameters:

  • model_id

    (int) - The numeric tool index to verbalize.

Returns:

  • str - Natural language description of the model structure.
ToolRegistry.explain(model_id: int, concept: str) -> str

Get detailed explanation of a concept within a specific tool.

Parameters:

  • model_id

    (int) - The numeric tool index containing the concept.
  • concept

    (str) - The concept name to explain.

Returns:

  • str - Natural language explanation of the concept.
ToolRegistry.query(model_id: int, query_dict: dict, limit: int = 1000) -> Any

Execute a query against a specific tool.

Parameters:

  • model_id

    (int) - The numeric tool index to query.
  • query_dict

    (dict) - Query parameters with "id" and "args" keys.
  • limit

    (int, default: 1000) - Maximum number of rows to return. Default: 1000.

Returns:

  • Any - Query results, typically as a pandas DataFrame.
 agent > cortex > tool
└──  ToolRegistry
    └──  add