Skip to content

Conversation

@sunyuhan1998
Copy link
Contributor

@sunyuhan1998 sunyuhan1998 commented Aug 11, 2025

As described in the issue, the current default order of SafeGuardAdvisor is lower than that of MessageChatMemoryAdvisor, which causes a problem: when users employ both advisors simultaneously without manually adjusting their order, if any historical message contains sensitive content, all subsequent messages will be blocked by SafeGuardAdvisor. This behavior is clearly undesirable.

This PR addresses the issue with the following changes:

  1. Adjusts the default priority of SafeGuardAdvisor to be higher than that of MessageChatMemoryAdvisor, ensuring that content filtering occurs before chat memory is stored.
  2. Enhances the documentation for SafeGuardAdvisor to alert users about this potential issue and recommend appropriate priority configuration based on their specific use cases.
  3. Add unit tests for the SafeGuardAdvisor.

Fixes: #4089

…rdAdvisor` to ensure it is always higher than that of `MessageChatMemoryAdvisor`, preventing sensitive terms in chat memory from repeatedly triggering `SafeGuardAdvisor`'s interception mechanism.

Signed-off-by: Sun Yuhan <[email protected]>
@sobychacko
Copy link
Contributor

@sunyuhan1998 It might be beneficial to verify the changes via a test. What do you think?

@sunyuhan1998
Copy link
Contributor Author

@sunyuhan1998 It might be beneficial to verify the changes via a test. What do you think?

No problem, I'll add the tests soon.

@sunyuhan1998
Copy link
Contributor Author

Hi @sobychacko , I noticed that SafeGuardAdvisor currently lacks unit tests, so I've added a comprehensive test class for it, which also includes the changes from this PR. Could you please review it again when you have a chance? Thanks!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The default order of SafeGuardAdvisor should be higher than MessageChatMemoryAdvisor

3 participants