Skip to content

Conversation

@roomote
Copy link
Collaborator

@roomote roomote commented Jun 30, 2025

Summary

This PR fixes issue #5162 where VS Code Language Model API responses were getting filtered with unhelpful error messages like "response got filtered FIX!!".

Problem

The VS Code Language Model API applies content filtering/safety mechanisms that can reject responses, but the current error handling in the VS Code LM provider only specifically handled vscode.CancellationError. When content filtering occurred, these errors were not properly detected and handled, leading to generic error messages instead of helpful guidance for users.

Solution

Enhanced the error handling in the VS Code Language Model provider (src/api/providers/vscode-lm.ts) by:

  1. Added content filtering detection: Implemented two new helper methods:

    • isContentFilteringError() - Detects filtering patterns in Error objects
    • isContentFilteringErrorObject() - Detects filtering patterns in error-like objects
  2. Pattern-based detection: Both methods check for keywords like:

    • 'filtered', 'content policy', 'inappropriate', 'safety', 'blocked', etc.
    • Case-insensitive matching for robust detection
  3. Enhanced error messages: When content filtering is detected, provides clear, actionable error messages that:

    • Explain that the content was filtered by VS Code's safety mechanisms
    • Suggest trying to rephrase the request
    • Maintain user-friendly guidance
  4. Comprehensive test coverage: Added extensive test suite (src/api/providers/__tests__/vscode-lm-content-filtering.test.ts) with 11 test cases covering:

    • Various content filtering error scenarios
    • Case-insensitive detection
    • Both Error objects and plain error objects
    • Proper error message formatting

Changes

  • Modified: src/api/providers/vscode-lm.ts

    • Enhanced createMessage() method error handling (lines 456-504)
    • Added isContentFilteringError() helper method
    • Added isContentFilteringErrorObject() helper method
  • Added: src/api/providers/__tests__/vscode-lm-content-filtering.test.ts

    • Comprehensive test suite for content filtering detection
    • 11 test cases covering various scenarios
    • Ensures robust error handling and user-friendly messages

Testing

All tests pass, including:

  • ✅ Existing VS Code LM provider tests
  • ✅ New content filtering detection tests
  • ✅ Linting and type checking across all packages

Impact

  • User Experience: Users will now receive clear, helpful error messages when content is filtered
  • Debugging: Easier to identify and resolve content filtering issues
  • Backward Compatibility: Maintains existing error handling for cancellation and other error types
  • Robustness: Case-insensitive pattern matching ensures reliable detection

Fixes #5162


Important

Enhanced error handling for content filtering in VS Code Language Model API with new detection methods and improved error messages.

  • Error Handling:
    • Added isContentFilteringError() and isContentFilteringErrorObject() in vscode-lm.ts to detect content filtering errors.
    • Enhanced createMessage() in vscode-lm.ts to provide clear error messages for content filtering.
  • Testing:
    • Added vscode-lm-content-filtering.test.ts with 11 test cases for content filtering detection and error message validation.
  • Misc:
    • Improved error message clarity and user guidance when content is filtered.

This description was created by Ellipsis for 186fe01. You can customize this summary. It will automatically update as commits are pushed.

…ndling

- Added specific error detection for VS Code content filtering scenarios
- Implemented helper methods to identify filtering errors in both Error objects and error-like objects
- Enhanced error messages to provide clear guidance when content is filtered
- Added comprehensive test coverage for content filtering detection
- Supports case-insensitive detection of filtering keywords like 'filtered', 'content policy', 'inappropriate', 'safety', 'blocked', etc.
- Maintains existing error handling for cancellation and other error types
@roomote roomote requested review from cte, jr and mrubens as code owners June 30, 2025 08:29
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Jun 30, 2025
@delve-auditor
Copy link

delve-auditor bot commented Jun 30, 2025

No security or compliance issues detected. Reviewed everything up to 186fe01.

Security Overview
  • 🔎 Scanned files: 2 changed file(s)
Detected Code Changes

The diff is too large to display a summary of code changes.

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jun 30, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jul 7, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

response got filtered FIX!!

3 participants