[PR #9568] fix(provider): Resolve unversioned google-vertex-anthropic model IDs to versioned ones #13152

Open
opened 2026-02-16 18:18:01 -05:00 by yindo · 0 comments
Owner

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

State: open
Merged: No


Why

When using the google-vertex-anthropic provider, model IDs like claude-sonnet-4-5 fail to match pricing data because models.dev stores them with date suffixes like claude-sonnet-4-5@20250929. This causes the pricing lookup to fail silently, defaulting costs to 0, resulting in sessions always showing $0.00 pricing.

fixes https://github.com/anomalyco/opencode/issues/9565

What

Add fallback logic in the getModel() function that:

  • Only applies to google-vertex-anthropic provider (not google-vertex)
  • Searches for versioned models matching the unversioned ID pattern
  • Returns the latest version (reverse-sorted by date suffix)
  • Maintains backward compatibility with versioned IDs
  • Falls back to standard error handling if no match is found

The fix is transparent to users - no configuration changes needed. Sessions now compute accurate costs from the resolved versioned model IDs.

Testing

Added 3 comprehensive tests:

  1. Unversioned model ID resolves to latest versioned model with correct pricing
  2. Backward compatibility: versioned model IDs still work directly
  3. Provider-specific: fallback only applies to google-vertex-anthropic, not google-vertex

All 69 provider tests pass.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9568 **State:** open **Merged:** No --- ## Why When using the google-vertex-anthropic provider, model IDs like `claude-sonnet-4-5` fail to match pricing data because models.dev stores them with date suffixes like `claude-sonnet-4-5@20250929`. This causes the pricing lookup to fail silently, defaulting costs to 0, resulting in sessions always showing \$0.00 pricing. fixes https://github.com/anomalyco/opencode/issues/9565 ## What Add fallback logic in the `getModel()` function that: - Only applies to google-vertex-anthropic provider (not google-vertex) - Searches for versioned models matching the unversioned ID pattern - Returns the latest version (reverse-sorted by date suffix) - Maintains backward compatibility with versioned IDs - Falls back to standard error handling if no match is found The fix is transparent to users - no configuration changes needed. Sessions now compute accurate costs from the resolved versioned model IDs. ## Testing Added 3 comprehensive tests: 1. Unversioned model ID resolves to latest versioned model with correct pricing 2. Backward compatibility: versioned model IDs still work directly 3. Provider-specific: fallback only applies to google-vertex-anthropic, not google-vertex All 69 provider tests pass.
yindo added the pull-request label 2026-02-16 18:18:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13152