Skip to content

feat: Add support for per-tool rail calls - #2239

Draft
JashG wants to merge 4 commits into
NVIDIA-NeMo:developfrom
JashG:jgulabrai/per-tool-call-rails
Draft

feat: Add support for per-tool rail calls#2239
JashG wants to merge 4 commits into
NVIDIA-NeMo:developfrom
JashG:jgulabrai/per-tool-call-rails

Conversation

@JashG

@JashG JashG commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Description

Adds two capabilities to the LLMRails tool rail pipeline:

  • Per-tool rail configuration (per_tool field on tool_output and tool_input): in config.yml, declare which rails apply to which tool. A tool not listed in per_tool receives the global flows only.
  • Parallel tool rail execution (parallel: true on tool_output / tool_input): global flows run concurrently using the same _run_flows_in_parallel infrastructure as input and output rails.

The execution of per-tool rails is backed by a new check tool call library rail. This is a library-supplied flow that reduces a per-tool check to a named prompt task — no Colang or Python required from the library consumer. Backed by a check_tool_call action that renders the prompt via llm_task_manager, calls llm_call(), and parses an ALLOW/BLOCK verdict from the model response.

The tool_name is now also included on ActivatedRail. per-tool rails will surface the tool name in the generation log for observability.

Both additions are backward compatible. Configurations without per_tool or parallel: true are unaffected.

Related Issue(s)

Verification

  • uv run --locked python qa/validate_tool_call_rails.py: 5 existing tool-rail regression cases, all pass
  • uv run --locked python qa/demo_per_tool_rails.py: live end-to-end demo against NVIDIA inference API (requires INFERENCE_API_KEY to be set)

AI Assistance

  • No AI tools were used.
  • AI tools were used; a human reviewed and can explain every change (tool: Claude Code).

Checklist

  • I've read the CONTRIBUTING guidelines.
  • This PR links to a triaged issue assigned to me.
  • My PR title follows the project commit convention.
  • I've updated the documentation if applicable.
  • I've added tests if applicable.
  • I've noted any verification beyond CI and any checks I couldn't run.
  • I did not update generated changelog files manually.
  • I addressed all CodeRabbit, Greptile, and other review comments, or replied with why no change is needed.
  • @mentions of the person or team responsible for reviewing proposed changes.

Signed-off-by: Jash Gulabrai <jashgulabrai98@gmail.com>
@github-actions github-actions Bot added size: XL status: needs triage New issues that have not yet been reviewed or categorized. labels Jul 30, 2026
JashG added 2 commits July 30, 2026 11:59
Signed-off-by: Jash Gulabrai <jashgulabrai98@gmail.com>
Signed-off-by: Jash Gulabrai <jashgulabrai98@gmail.com>
@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.77273% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
nemoguardrails/colang/v1_0/runtime/runtime.py 75.00% 5 Missing ⚠️
nemoguardrails/library/tool_call_check/actions.py 92.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

Signed-off-by: Jash Gulabrai <jashgulabrai98@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: XL status: needs triage New issues that have not yet been reviewed or categorized.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant