Repository navigation
Conversation
…g the scan A prompt refused by the provider's content filter (ContentPolicyViolationError) or longer than the model's context window (ContextWindowExceededError) was raised as BadGeneratorException, ending the whole scan. Red-teaming probes are designed to trip content filters, so a scan of a filtered deployment through LiteLLM could stop at its first filtered prompt. Both exceptions are litellm BadRequestError subclasses that NVIDIA#820 grouped with unrecoverable configuration errors. Catch them separately, log a warning, and return None for each requested generation, matching OpenAIGenerator's handling of openai.BadRequestError. Other BadRequestError subclasses such as configuration errors still stop the scan. Fixes NVIDIA#2523 Signed-off-by: hakarrr <191973953+hakarrr@users.noreply.github.com> Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
hakarrr
force-pushed
the
fix/litellm-skip-prompt-rejections
branch
from
December 5, 2026 18:50
de5bd90 to
01bcae5
Compare
This branch has not been deployed
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.
Fixes #2523
What this changes
LiteLLMGeneratorraisedBadGeneratorExceptionforContentPolicyViolationErrorandContextWindowExceededError, so one provider-filtered prompt ended the whole scan. Probes are meant to trip content filters, so a scan against a filtered deployment could stop at its first filtered prompt.Both errors are now caught separately. The generator logs a warning and returns
Nonefor each requested generation, the same wayOpenAIGeneratorhandlesopenai.BadRequestError. OtherBadRequestErrorsubclasses (for example configuration errors) still raise.Not a duplicate
I searched open PRs for #2523 and for LiteLLM generator changes. The open LiteLLM PRs cover rate-limit backoff (#2331) and system prompt support (#2519), not content-policy or context-window rejections.
Tests
python -m pytest tests/generators/test_litellm.py: 5 passed, 2 skipped (they need live API keys). The 2 new tests fail on unpatched main and pass with the change.blackis clean.AI disclosure
This change was made with AI assistance. I reviewed every changed line and ran the tests locally.