Skip to content

splitKnownProviderModel strips provider prefix when model ID contains known provider alias #3252

Description

@v2up-32mb

Bug Description

The splitKnownProviderModel function in pkg/providers/factory.go incorrectly strips the provider prefix from model IDs when the model ID itself contains a known provider alias.

Steps to Reproduce

  1. Configure a model with a known provider prefix, e.g.:
    { "model": "google/gemini-3.1-flash-lite-preview" }
  2. The google prefix is a known provider alias (resolves to google-vertex-ai)
  3. splitKnownProviderModel identifies google as a known provider and strips it
  4. The returned modelID becomes gemini-3.1-flash-lite-preview (without google/ prefix)
  5. This causes the wrong model to be used in downstream requests

Expected Behavior

When the model string already contains an explicit provider prefix (e.g., google/gemini-3.1-flash-lite-preview), the function should either:

  • Return the model as-is without modification, OR
  • Only strip the prefix if it actually needs to be resolved (i.e., when the model ID does not already contain a /)

Root Cause

In pkg/providers/factory.go, the splitKnownProviderModel function checks if the first segment is a known provider alias and strips it unconditionally, without checking whether the original model string already had an explicit provider prefix.

Suggested Fix

The function should check whether the model string already contains a / before stripping the prefix. If it does, the model should be returned unchanged.

// Pseudo-code for the fix
func splitKnownProviderModel(model string) (provider, modelID string) {
    // If model already contains a provider prefix (has '/'), return as-is
    if strings.Contains(model, "/") {
        return "", model
    }
    // ... existing logic
}

Or more precisely, only strip the prefix when the model ID itself starts with a known provider alias and the original string did not already have a /.

Environment

  • picoclaw version: latest
  • Go version: 1.25+

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions