Skip to content

fix(models): add request sanitization#3165

Merged
waleedlatif1 merged 1 commit intostagingfrom
fix/m
Feb 8, 2026
Merged

fix(models): add request sanitization#3165
waleedlatif1 merged 1 commit intostagingfrom
fix/m

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • add request sanitization

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Feb 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 8, 2026 3:04am

Request Review

@waleedlatif1 waleedlatif1 merged commit f9b885f into staging Feb 8, 2026
7 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/m branch February 8, 2026 03:04
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 8, 2026

Greptile Overview

Greptile Summary

Extended request sanitization to handle model-specific parameters (reasoningEffort, verbosity, thinkingLevel) in addition to existing temperature handling. The sanitizeRequest function now removes these parameters when models don't support them, preventing API errors when unsupported parameters are sent to provider APIs.

Key changes:

  • Added three new capability check functions in utils.ts that follow the existing pattern (checking against model lists with case-insensitive comparison)
  • Extended sanitizeRequest in index.ts to filter out reasoningEffort, verbosity, and thinkingLevel for models that don't support these features
  • Added comprehensive test coverage for all three new capability functions

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation follows established patterns in the codebase (consistent with existing supportsTemperature function), includes comprehensive test coverage for all new functions, and the changes are straightforward parameter filtering that prevents API errors without affecting logic
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/providers/index.ts Extended sanitizeRequest to remove unsupported model parameters (reasoningEffort, verbosity, thinkingLevel) based on model capabilities
apps/sim/providers/utils.ts Added three new capability check functions (supportsReasoningEffort, supportsVerbosity, supportsThinking) following existing patterns
apps/sim/providers/utils.test.ts Added comprehensive test coverage for the three new capability functions with positive, negative, and case-insensitive test cases

Sequence Diagram

sequenceDiagram
    participant Client
    participant ProvidersIndex as providers/index.ts
    participant SanitizeRequest as sanitizeRequest()
    participant Utils as providers/utils.ts
    participant Provider as Provider Executor

    Client->>ProvidersIndex: executeRequest(request)
    ProvidersIndex->>SanitizeRequest: sanitizeRequest(request)
    
    SanitizeRequest->>Utils: supportsTemperature(model)
    Utils-->>SanitizeRequest: boolean
    alt !supportsTemperature
        SanitizeRequest->>SanitizeRequest: temperature = undefined
    end
    
    SanitizeRequest->>Utils: supportsReasoningEffort(model)
    Utils-->>SanitizeRequest: boolean
    alt !supportsReasoningEffort
        SanitizeRequest->>SanitizeRequest: reasoningEffort = undefined
    end
    
    SanitizeRequest->>Utils: supportsVerbosity(model)
    Utils-->>SanitizeRequest: boolean
    alt !supportsVerbosity
        SanitizeRequest->>SanitizeRequest: verbosity = undefined
    end
    
    SanitizeRequest->>Utils: supportsThinking(model)
    Utils-->>SanitizeRequest: boolean
    alt !supportsThinking
        SanitizeRequest->>SanitizeRequest: thinkingLevel = undefined
    end
    
    SanitizeRequest-->>ProvidersIndex: sanitizedRequest
    ProvidersIndex->>Provider: executeRequest(sanitizedRequest)
    Provider-->>Client: response
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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.

1 participant