fix(v2): clear output_rails_in_progress after output-rail abort - #2208
Draft
MuneezaAzmat wants to merge 1 commit into
Draft
fix(v2): clear output_rails_in_progress after output-rail abort#2208MuneezaAzmat wants to merge 1 commit into
MuneezaAzmat wants to merge 1 commit into
Conversation
When an output rail aborted, run output rails never cleared the reentrancy flag, so later turns in the same session skipped output rails. Catch success and failure with when/else, reset the flag on both paths, and re-abort on failure so blocked text is still withheld. Fixes NVIDIA-NeMo#2067 Signed-off-by: Muneeza Azmat <muneezaazmat@utexas.edu> Co-authored-by: Cursor <cursoragent@cursor.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.
Summary
$output_rails_in_progressstayingTrueafter an output railabort, which caused later turns in the same session to skip output rails (bug(v2): output rails silently stop firing after first abort in multi-turn conversations. #2067).run output railsinguardrails.coto usewhen/else: clear the flag on both success and failure, then re-aborton failure so blocked bot text is still not uttered.Approach
Per maintainer guidance on #2067: reset the flag whether the rail passes or aborts, while still preventing rejected output from being sent. Nested
bot sayfrom inside rails remains protected while the flag is set.Test plan
poetry run pytest tests/v2_x/test_output_rails_abort_multiturn.py -vpoetry run pytest tests/v2_x/test_input_output_rails_transformations.py -vpoetry run pre-commit run --files nemoguardrails/colang/v2_x/library/guardrails.co tests/v2_x/test_output_rails_abort_multiturn.pyFixes #2067
Made with Cursor