Skip to content

Callees

callees

CalleesTool — find functions called by a symbol.

CalleesTool

Bases: AXMTool

Find all functions/methods called by a given symbol.

Registered as ast_callees via axm.tools entry point. This is the inverse of ast_callers: given a function name, returns all call-sites within that function body.

Source code in packages/axm-ast/src/axm_ast/tools/callees.py
class CalleesTool(AXMTool):
    """Find all functions/methods called by a given symbol.

    Registered as ``ast_callees`` via axm.tools entry point.
    This is the inverse of ``ast_callers``: given a function name,
    returns all call-sites *within* that function body.
    """

    agent_hint: str = (
        "Find all functions called by a symbol"
        " — the inverse of ast_callers."
        " Returns call-sites with symbol, module, line."
    )

    @property
    def name(self) -> str:
        """Return tool name for registry lookup."""
        return "ast_callees"

    def execute(
        self, *, path: str = ".", symbol: str | None = None, **kwargs: Any
    ) -> ToolResult:
        """Find all callees of a symbol.

        Args:
            path: Path to package or workspace directory.
            symbol: Symbol name to search for (required).

        Returns:
            ToolResult with callee list.
        """
        if not symbol:
            return ToolResult(success=False, error="symbol parameter is required")

        try:
            project_path = Path(path).resolve()
            if not project_path.is_dir():
                return ToolResult(
                    success=False, error=f"Not a directory: {project_path}"
                )

            from axm_ast.core.cache import get_package
            from axm_ast.core.flows import find_callees

            pkg = get_package(project_path)
            callees = find_callees(pkg, symbol)

            callee_data = [
                {
                    "module": c.module,
                    "symbol": c.symbol,
                    "line": c.line,
                    "context": c.context,
                    "call_expression": c.call_expression,
                }
                for c in callees
            ]

            return ToolResult(
                success=True,
                data={"callees": callee_data, "count": len(callee_data)},
                hint=(
                    "Tip: Use ast_callers(symbol) for the inverse"
                    " — who calls this function."
                ),
            )
        except Exception as exc:
            return ToolResult(success=False, error=str(exc))
name property

Return tool name for registry lookup.

execute(*, path='.', symbol=None, **kwargs)

Find all callees of a symbol.

Parameters:

Name Type Description Default
path str

Path to package or workspace directory.

'.'
symbol str | None

Symbol name to search for (required).

None

Returns:

Type Description
ToolResult

ToolResult with callee list.

Source code in packages/axm-ast/src/axm_ast/tools/callees.py
def execute(
    self, *, path: str = ".", symbol: str | None = None, **kwargs: Any
) -> ToolResult:
    """Find all callees of a symbol.

    Args:
        path: Path to package or workspace directory.
        symbol: Symbol name to search for (required).

    Returns:
        ToolResult with callee list.
    """
    if not symbol:
        return ToolResult(success=False, error="symbol parameter is required")

    try:
        project_path = Path(path).resolve()
        if not project_path.is_dir():
            return ToolResult(
                success=False, error=f"Not a directory: {project_path}"
            )

        from axm_ast.core.cache import get_package
        from axm_ast.core.flows import find_callees

        pkg = get_package(project_path)
        callees = find_callees(pkg, symbol)

        callee_data = [
            {
                "module": c.module,
                "symbol": c.symbol,
                "line": c.line,
                "context": c.context,
                "call_expression": c.call_expression,
            }
            for c in callees
        ]

        return ToolResult(
            success=True,
            data={"callees": callee_data, "count": len(callee_data)},
            hint=(
                "Tip: Use ast_callers(symbol) for the inverse"
                " — who calls this function."
            ),
        )
    except Exception as exc:
        return ToolResult(success=False, error=str(exc))