fix(tests): broaden refusal markers in realtime guardrail flake check - #28437
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(tests): broaden refusal markers in realtime guardrail flake check#28437cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
gpt-realtime nondeterministically phrases its refusal of the guardrail's "say exactly: ..." prompt. Recent CI failure example: "Sorry, I can't say that. It contains a forbidden phrase. Would you like me to help in another way?" This is clearly a refusal but did not match any existing safe marker (no leading 'I'm sorry', no 'can't repeat', no 'can't assist'). Add 'sorry', 'forbidden', 'i can't', 'i cannot', and 'can't say'/'cannot say' to the marker list so we accept the full range of refusal phrasings the model produces. The hard invariant - that the blocked phrase itself must not leak into AI output - is unchanged. Co-authored-by: Krrish Dholakia <krrish-berri-2@users.noreply.github.com>
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
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.
Title
fix(tests): broaden refusal markers in realtime guardrail flake check
Relevant issues
CI autofix for
realtime_translation_testingjob failure onlitellm_internal_staging.Pre-Submission checklist
tests/litellm/directory — this PR only edits an existing test.make test-unitand ensure it passes.Type
Bug Fix
Changes
The
test_text_message_blocked_by_guardrail_no_ai_responsetest makes a real call to OpenAI's realtime API and asserts that, after the guardrail blocks the user's input, any AI response contains a refusal marker (so the model didn't simply answer a different way). The model's refusal phrasing is non-deterministic. A previous fix (#28200) already had to add Unicode quote normalization for the same reason.Latest CI failure on the staging branch:
That string is clearly a refusal (
Sorry, I can't say that,forbidden phrase) but matched none of the existing markers (i'm sorry,can't repeat,can't assist,unable to, ...).This PR widens the marker set to also accept
sorry,forbidden,i can't,i cannot, andcan't say/cannot say. The hard invariant — that the blocked phrase itself must not leak into AI output — is unchanged.