Skip to content

Conversation

@felarof99
Copy link
Contributor

No description provided.

@felarof99
Copy link
Contributor Author

I don't think this is the right fix. @shivammittal274 shouldn't vercel AI SDK handle these for us, could you take look?

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 28, 2025

Greptile Overview

Greptile Summary

Fixed a compatibility issue where Anthropic models fail when both topP and temperature parameters are passed. The fix introduces a getSamplingParams() method that conditionally omits topP for Anthropic and BrowserOS providers while keeping it for other providers.

Key changes:

  • Added provider field to track which AI provider is being used
  • Created getSamplingParams() helper that returns only temperature for @anthropic and @browseros, but both temperature and topP for other providers
  • Applied the conditional logic to both generateContent() and generateContentStream() methods

Suggestions:

  • Consider adding unit tests to verify the parameter filtering works correctly for different providers

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk
  • The fix is straightforward and addresses a real API compatibility issue. The implementation is clean and follows the existing code patterns. Score is 4 instead of 5 due to lack of unit tests for the new functionality.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/agent/src/agent/gemini-vercel-sdk-adapter/index.ts 4/5 Added provider-specific sampling parameter handling to fix Anthropic compatibility issue. Implementation is clean but lacks tests.

Sequence Diagram

sequenceDiagram
    participant Client
    participant ContentGenerator
    participant getSamplingParams
    participant VercelAI
    participant Provider

    Client->>ContentGenerator: generateContent(request)
    ContentGenerator->>getSamplingParams: getSamplingParams(temperature, topP)
    
    alt Provider is Anthropic or BrowserOS
        getSamplingParams-->>ContentGenerator: {temperature}
    else Other providers
        getSamplingParams-->>ContentGenerator: {temperature, topP}
    end
    
    ContentGenerator->>VercelAI: generateText({model, messages, ...samplingParams})
    VercelAI->>Provider: API call with filtered params
    Provider-->>VercelAI: response
    VercelAI-->>ContentGenerator: result
    ContentGenerator-->>Client: GenerateContentResponse
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.

1 file 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.

2 participants