opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(provider): normalize model API IDs with slashes for abacus compatibility

Open LIHUA919 opened this issue 1 day ago • 1 comments

Fixes #8780

Summary

Models with slashes in their IDs (e.g., `deepseek-ai/DeepSeek-V3.2`) were not working correctly with providers like abacus that use `org/model` naming conventions. The models would output raw commands instead of executing them.

Root Cause

When users configure models using the full slug as the model key (e.g., `"deepseek-ai/DeepSeek-V3.2"`), the `api.id` field was set to the full slug including the organization prefix. This caused issues with:

  1. The AI SDK not correctly parsing model IDs with `/`
  2. The abacus API expecting model IDs without the organization prefix

Solution

Added a `normalizeModelAPIID()` helper function that:

  • Extracts only the model name from `org/model` format for API calls
  • Preserves the full identifier for internal lookups
  • Only applies when no explicit `id` field is provided (maintains backward compatibility)

Changes

  • packages/opencode/src/provider/provider.ts: Add normalization logic
  • packages/opencode/test/provider/provider.test.ts: Add comprehensive test coverage

Example Behavior

{
  "provider": {
    "abacus": {
      "models": {
        "deepseek-ai/DeepSeek-V3.2": {
          "name": "DeepSeek V3.2"
        }
      }
    }
  }
}

Result:

  • `model.id` = `"deepseek-ai/DeepSeek-V3.2"` (used for internal lookups)
  • `model.api.id` = `"DeepSeek-V3.2"` (used for API calls)

Test Coverage

Added tests for:

  • Models with single slash: `deepseek-ai/DeepSeek-V3.2`
  • Models with multiple slashes: `Qwen/Qwen2.5-72B-Instruct`
  • Verification that internal IDs preserve full identifier
  • Verification that API IDs are correctly normalized

🤖 Generated with Claude Code

LIHUA919 avatar Jan 17 '26 09:01 LIHUA919