Skip to content

Tool

relationalai.agent.cortex.tool

Abstract base class for RAI-powered tools that can be used by Cortex agents.

A Tool provides semantic data exploration capabilities through a consistent interface:

  • Discovery: What models and concepts are available?
  • Verbalization: Detailed model structure and relationships
  • Explanation: Business rules and semantics for specific concepts
  • Querying: Execute structured queries against the data model

Implement this interface to create custom tools, or use DefaultTool for standard RAI model-based tools.

Tool.description() -> str

Return a human-readable description of this tool’s purpose.

Returns:

  • str - A description of the tool.
Tool.concepts() -> List[str]

Return list of key concept names available in this tool’s domain.

Returns:

  • list of str - Concept names available in this tool.
Tool.verbalize() -> str

Return detailed structure and relationships for the entire model.

Returns:

  • str - A natural language description of the model structure.
Tool.explain(concept: str) -> str

Return detailed explanation of business rules for a specific concept.

Parameters:

  • concept

    (str) - The name of the concept to explain.

Returns:

  • str - A natural language explanation of the concept.
Tool.queries() -> dict

Return available pre-defined queries.

If queries capability is not configured, returns a message explaining that no queries are available.

Returns:

  • dict - Dict with "queries" and "query_instructions" if configured, or a dict with "message" explaining queries are not available.
Tool.query(params: dict) -> Union[rai.Fragment, pandas.DataFrame]

Execute a query against this tool’s model and return results.

Parameters:

  • params

    (dict) - Query parameters including "id" (query identifier) and "args" (query arguments).

Returns:

  • relationalai.semantics.Fragment or pandas.DataFrame - Query results.

Raises:

  • ValueError - If queries capability is not configured.
  • KeyError - If query ID is not found.
Toolabc.ABC
 agent > cortex > tool
└──  ToolRegistry
    └──  add