feat: Add support for per-tool rail calls - #2239
Draft
JashG wants to merge 4 commits into
Draft
Conversation
Signed-off-by: Jash Gulabrai <jashgulabrai98@gmail.com>
Signed-off-by: Jash Gulabrai <jashgulabrai98@gmail.com>
Signed-off-by: Jash Gulabrai <jashgulabrai98@gmail.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Signed-off-by: Jash Gulabrai <jashgulabrai98@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds two capabilities to the
LLMRailstool rail pipeline:per_toolfield ontool_outputandtool_input): inconfig.yml, declare which rails apply to which tool. A tool not listed inper_toolreceives the global flows only.parallel: trueontool_output/tool_input): global flows run concurrently using the same_run_flows_in_parallelinfrastructure as input and output rails.The execution of per-tool rails is backed by a new
check tool calllibrary 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 acheck_tool_callaction that renders the prompt viallm_task_manager, callsllm_call(), and parses anALLOW/BLOCKverdict from the model response.The
tool_nameis 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_toolorparallel: trueare unaffected.Related Issue(s)
Verification
uv run --locked python qa/validate_tool_call_rails.py: 5 existing tool-rail regression cases, all passuv run --locked python qa/demo_per_tool_rails.py: live end-to-end demo against NVIDIA inference API (requiresINFERENCE_API_KEYto be set)AI Assistance
Checklist