Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • added vertex to all LLM-based blocks
    • marked location and project ID as required
  • fixed refresh bc it was using vertex as the base when it should've been using google since thats the parent service

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 Dec 23, 2025

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

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Dec 23, 2025 9:04pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 23, 2025

Greptile Summary

This PR adds Vertex AI OAuth support across all LLM-based blocks (Agent, Evaluator, Router, Translate) and fixes a critical bug in OAuth token refresh.

Key Changes:

  • Added vertexCredential OAuth input field to Evaluator, Router, and Translate blocks (Agent already had it)
  • Marked Vertex AI project and location fields as required across all blocks
  • Updated API key visibility logic to hide the API key field when Vertex models are selected (OAuth is used instead)
  • Added credential resolution logic in block handlers to fetch and refresh OAuth authentication
  • Fixed OAuth token refresh bug: previously used vertex as base provider (incorrect), now correctly maps vertex-ai service to google base provider using getBaseProviderForService() function

Implementation Details:

  • Block definitions now conditionally show OAuth input and hide API key when Vertex models are selected
  • Block handlers (evaluator, router) resolve vertexCredential to authentication before making API calls
  • The /api/providers route handles vertexCredential parameter and resolves it before provider execution
  • OAuth refresh logic now properly traverses the provider service hierarchy to find the correct base provider

Confidence Score: 5/5

  • This PR is safe to merge with no concerns
  • The changes are well-structured and consistent across all affected blocks. The OAuth token refresh fix addresses a real bug that would have caused authentication failures. All changes follow established patterns in the codebase, and the implementation is complete with proper parameter passing through all layers (blocks → handlers → API routes).
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/lib/oauth/oauth.ts Fixed OAuth token refresh to correctly map vertex-ai service to google base provider
apps/sim/app/api/providers/route.ts Added vertexCredential parameter handling and OAuth token resolution for Vertex AI
apps/sim/blocks/blocks/evaluator.ts Added Vertex AI OAuth support with required fields and updated API key visibility logic
apps/sim/blocks/blocks/router.ts Added Vertex AI OAuth support with required fields and updated API key visibility logic
apps/sim/blocks/blocks/translate.ts Added Vertex AI OAuth support with required fields and updated API key visibility logic
apps/sim/executor/handlers/evaluator/evaluator-handler.ts Added Vertex AI OAuth credential resolution and parameter passing
apps/sim/executor/handlers/router/router-handler.ts Added Vertex AI OAuth credential resolution and parameter passing

Sequence Diagram

sequenceDiagram
    participant User
    participant Block as LLM Block<br/>(Evaluator/Router/Translate/Agent)
    participant Handler as Block Handler
    participant ProvidersAPI as /api/providers
    participant OAuth as OAuth Utils
    participant DB as Database
    participant Vertex as Vertex AI API

    User->>Block: Select Vertex model
    Block->>User: Show OAuth input plus required fields
    User->>Block: Authenticate and provide project location
    Block->>Handler: Execute with vertexCredential ID
    Handler->>DB: Query credential by ID
    DB-->>Handler: Return credential record
    Handler->>OAuth: Call refreshTokenIfNeeded
    OAuth->>OAuth: Map vertex-ai service to google base
    OAuth->>Vertex: Request updated authentication
    Vertex-->>OAuth: Provide updated authentication
    OAuth-->>Handler: Return authentication
    Handler->>ProvidersAPI: POST request with authentication
    ProvidersAPI->>DB: Query credential again
    DB-->>ProvidersAPI: Return credential record
    ProvidersAPI->>OAuth: Call refreshTokenIfNeeded
    OAuth-->>ProvidersAPI: Return authentication
    ProvidersAPI->>Vertex: Make API call
    Vertex-->>ProvidersAPI: LLM response
    ProvidersAPI-->>Handler: Response
    Handler-->>Block: Execution result
    Block-->>User: Display output
Loading

@waleedlatif1 waleedlatif1 merged commit 89c1085 into staging Dec 23, 2025
10 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/vertex branch December 23, 2025 21:11
waleedlatif1 added a commit that referenced this pull request Dec 23, 2025
…esh (#2555)

* improvement(vertex): added vertex to all LLM-based blocks, fixed refresh

* fix build
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