Skip to content

Model selector shows no models when provider payload omits cost.cache #129

Closed

Description

@GammelSami

The model selector can show an empty list even though providers are connected and /api/opencode/provider returns models.

Root cause

In frontend/src/api/providers.ts (getProvidersFromOpenCodeServer), model mapping assumes openCodeModel.cost.cache.read/write always exists.
Some models (e.g. Google models like gemini-embedding-001) return cost without cache, which throws at runtime.
The outer try/catch then returns an empty provider list.

Reproduce

  1. Connect providers (e.g. Google/OpenAI) via WebUI or mounted auth (both reproduce).
  2. Open model selection dialog.
  3. Ensure /api/opencode/provider includes a model with cost but no cost.cache.
  4. Result: no models are shown in UI.

Expected

Missing optional fields in one model should not break the full provider/model list.

Actual

A single malformed/partial model entry causes the whole list to fail and the UI shows no models.

Suggested fix

  • Make mapping defensive:
    • cache_read: openCodeModel.cost?.cache?.read ?? 0
    • cache_write: openCodeModel.cost?.cache?.write ?? 0
  • Optionally isolate errors per model/provider so one bad entry doesn't drop the entire list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions