Skip to content

refactor: introduce modelsdev.ID for provider-qualified model identity#2766

Merged
dgageot merged 1 commit into
docker:mainfrom
dgageot:board/17cc848969828a05
May 12, 2026
Merged

refactor: introduce modelsdev.ID for provider-qualified model identity#2766
dgageot merged 1 commit into
docker:mainfrom
dgageot:board/17cc848969828a05

Conversation

@dgageot
Copy link
Copy Markdown
Member

@dgageot dgageot commented May 12, 2026

Fixes #2743.

Replaces bare string model identifiers with a strongly-typed
modelsdev.ID (provider + model name) on the API surface that
the issue called out as bug-prone, so the compiler refuses
unqualified model strings where a provider/model pair is
required.

What changes

New type — pkg/modelsdev/id.go:

  • ID{Provider, Model} with NewID, ParseID, ParseIDOrZero,
    String, IsZero, IsValid.

API now takes/returns modelsdev.ID instead of string:

  • modelsdev.Store.GetModel, runtime.ModelStore.
  • provider.Provider.ID() and base.Config.ID(), plus all
    implementations (anthropic, bedrock, gemini, openai, oaistream,
    dmr, vertexai/modelgarden, rulebased, …).
  • modelinfo.LoadCaps, modelinfo.IsClaude,
    modelinfo.LookupFamily.
  • oaistream.ConvertMessages / ConvertMultiContent,
    bedrock.convertMessages, gemini.convertMessagesToGemini,
    the per-provider convertDocument helpers,
    bedrock.detectCachingSupport.
  • rulebased.Client.LastSelectedModelID.
  • Embedding/RAG: strategy.EmbeddingConfig.ModelID,
    strategy.VectorStoreConfig.ModelID, internal modelStore
    interface, calculateSemanticUsageCost.

Internal adapters:

  • runtime.getAgentModelID / getEffectiveModelID return
    modelsdev.ID; agent-info events convert via .String() at
    the boundary.
  • team.AgentInfo reads Provider/Model from the ID directly
    instead of splitting a string.
  • runtime.strip_modalities parses hooks.Input.ModelID via
    modelsdev.ParseID.

Why

Several call sites used to pass a bare model name (e.g.
"claude-sonnet-4-6") where a provider/model pair was
expected. The compiler had no way to flag these mistakes and they
silently fell through to "model not found" lookups. Lifting the
identity to a dedicated type makes the contract explicit and
unforgeable.

@dgageot dgageot requested a review from a team as a code owner May 12, 2026 09:12
@dgageot dgageot force-pushed the board/17cc848969828a05 branch from 106d0ca to 9386e47 Compare May 12, 2026 10:18
@dgageot dgageot merged commit 71ec528 into docker:main May 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants