nemoguardrails.guardrails.tool_rail_action
nemoguardrails.guardrails.tool_rail_action
Base class for IORails tool-calling rails.
Tool rails are local structural/schema validators. Unlike RailAction they make
no LLM or API call, render no prompt, and need no model: they take already-normalized
tool data (a Toolset, the model’s ToolCall list, or incoming ToolResult
objects — all produced by the engine adapter) and return a RailResult.
requires_model is therefore False and the only collaborator is an optional
tracer for spans.
Subclasses set :attr:ToolRailAction.action_name and implement an async run with
their own typed inputs (the inputs differ per rail), performing the check through
:meth:ToolRailAction._guarded so every rail gets a consistent action span and turns
an unexpected error into a blocking result rather than letting it propagate.
Module Contents
Classes
Data
API
Base for the local, model-free tool-calling rails (tool-call and tool-result).
Run check inside an action span, converting any error into a block.
Mirrors RailAction’s error contract: an unexpected exception is recorded
on the span and returned as RailResult(is_safe=False, ...) so a malformed
input or a rail bug fails closed rather than crashing the request.