[PR #11020] fix(provider): include providerID in SDK cache key #13630

Closed
opened 2026-02-16 18:18:28 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/11020

State: closed
Merged: Yes


Fixes #7514

Problem

When switching between different providers on Vertex AI (e.g., from an Anthropic model to a Gemini model), the SDK cache would return the wrong cached instance. This caused incorrect API URLs like:

https://aiplatform.googleapis.com/v1/projects/.../publishers/anthropic/models/gemini-3-flash-preview:streamRawPredict

Root Cause

The SDK cache key was computed using only { npm, options }, but both google-vertex and google-vertex-anthropic providers share the same npm package (@ai-sdk/google-vertex) with similar options (project, location).

Solution

Include providerID in the SDK cache key:

// Before
const key = Bun.hash.xxHash32(JSON.stringify({ npm: model.api.npm, options }))

// After
const key = Bun.hash.xxHash32(JSON.stringify({ providerID: model.providerID, npm: model.api.npm, options }))

Verification

Tested by switching between Anthropic and Gemini models on Vertex AI - each now correctly uses its own SDK instance with proper publisher URLs.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11020 **State:** closed **Merged:** Yes --- Fixes #7514 ## Problem When switching between different providers on Vertex AI (e.g., from an Anthropic model to a Gemini model), the SDK cache would return the wrong cached instance. This caused incorrect API URLs like: ``` https://aiplatform.googleapis.com/v1/projects/.../publishers/anthropic/models/gemini-3-flash-preview:streamRawPredict ``` ## Root Cause The SDK cache key was computed using only `{ npm, options }`, but both `google-vertex` and `google-vertex-anthropic` providers share the same npm package (`@ai-sdk/google-vertex`) with similar options (project, location). ## Solution Include `providerID` in the SDK cache key: ```typescript // Before const key = Bun.hash.xxHash32(JSON.stringify({ npm: model.api.npm, options })) // After const key = Bun.hash.xxHash32(JSON.stringify({ providerID: model.providerID, npm: model.api.npm, options })) ``` ## Verification Tested by switching between Anthropic and Gemini models on Vertex AI - each now correctly uses its own SDK instance with proper publisher URLs.
yindo added the pull-request label 2026-02-16 18:18:28 -05:00
yindo closed this issue 2026-02-16 18:18:28 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13630