Skip to content

Skip provider-rejected prompts in LiteLLMGenerator instead of aborting the scan - #2575

Open
hakarrr wants to merge 1 commit into
NVIDIA:mainfrom
hakarrr:fix/litellm-skip-prompt-rejections
Open

hakarrr wants to merge 1 commit into
NVIDIA:mainfrom
hakarrr:fix/litellm-skip-prompt-rejections

Conversation

@hakarrr

@hakarrr hakarrr commented Dec 1, 2026

Copy link
Copy Markdown

Fixes #2523

What this changes

LiteLLMGenerator raised BadGeneratorException for ContentPolicyViolationError and ContextWindowExceededError, 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 None for each requested generation, the same way OpenAIGenerator handles openai.BadRequestError. Other BadRequestError subclasses (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. black is clean.

AI disclosure

This change was made with AI assistance. I reviewed every changed line and ran the tests locally.

…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
hakarrr force-pushed the fix/litellm-skip-prompt-rejections branch from de5bd90 to 01bcae5 Compare December 5, 2026 18:50

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LiteLLM generator: one content-filtered or too-long prompt aborts the whole scan

1 participant