Repository navigation
fix(guardrails): restore Azure guardrail get_user_prompt dispatch and allow logging #44067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1ccda8f
fix(guardrails): restore Azure guardrail get_user_prompt dispatch and…
yucheng-berri ca1f5a0
test(guardrails): use transport-level doubles in Azure dispatch regre…
yucheng-berri 8ca98df
test(guardrails): add Azure dispatch audit matrix integration cells
yucheng-berri ac0e8bd
test(guardrails): restore global callback lists after Router reset in…
yucheng-berri 53e6e47
test(guardrails): make proxy restart cell independent of shutdown timing
yucheng-berri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Tuple messages break list-based prompt overrides
For tuple messages,
get_user_prompt_from_requestpasses a tuple to list-basedget_user_promptoverrides. An override callingmessages.copy()fails before Azure scans the prompt.Learn more
The shared Azure base extracts user text from chat messages. SDK callers and earlier pre-call guardrails can supply tuples, but
get_user_promptadvertises a list to subclasses. The dispatch passes the tuple unchanged, so an override using a valid list method fails before either Azure guardrail scans it. The built-in implementation happens to work because it only iterates backward.Example: An earlier hook writes
data["messages"] = ({"role": "user", "content": "hello"},). An override usesmessages.copy()before choosing which turns to scan. It receives a tuple and raises instead of sending "hello" to Azure.Recommended fix: Convert tuple messages to a list before calling
self.get_user_prompt, while preserving the list object for list-valued messages. Add a test with an override that uses a list operation on tuple input.Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches the pre-#43786 parent, which passed the tuple unchanged to self.get_user_prompt. Converting to list is new behavior, so I'm leaving it for the maintainer