Skip to content

refactor: introduce type-safe modelsdev.ID throughout the codebase (Provider.ID(), Store.GetModel, etc.) #2743

@simonferquel-clanker

Description

@simonferquel-clanker

Background

During review of PR #2738, several type-safety improvements were proposed and implemented, but ultimately deemed too large to include in the original bugfix PR. This issue tracks them as a follow-up.

Proposed changes

  1. modelsdev.ID struct — Add ID{Provider, Model string}, NewID, ParseID, ParseIDOrZero, String() to pkg/modelsdev
  2. Store.GetModel(ctx, ID) — Change from bare string to modelsdev.ID, so the compiler prevents passing unqualified model names
  3. Provider.ID() modelsdev.ID — Change the provider.Provider interface method to return modelsdev.ID instead of string
  4. base.Config.ID() and ModelCapsID() — Return modelsdev.ID
  5. modelcaps.Load / LoadFromStore — Accept modelsdev.ID instead of string
  6. All downstream callersgetEffectiveModelID, calculateSemanticUsageCost, VectorStore.modelID, EmbeddingConfig.ModelID, rulebased.LastSelectedModelID, team.go, runtime.go, rag/strategy, teamloader, modelinfo, etc.

Motivation

The original bug (#2737) existed because modelcaps.Load took a bare string and callers accidentally passed just the model name (e.g. "claude-sonnet-4-6") instead of the required "provider/model" format. A struct type makes this class of error impossible to compile.

Scope

This is a significant but mechanical refactor — ~50 call sites, mostly renaming string to modelsdev.ID and calling .String() at the boundaries where strings are required (slog, event payloads, etc.).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions