Skip to content

Case mismatch in custom provider model name breaks context_limit lookup #8752

@d3dat

Description

@d3dat

Bug

When a custom provider is created through the UI/CLI, the model name is saved as-is (preserving the original case, e.g. GLM-5.1). However, when goose resolves the model's context_limit at runtime, it performs a strict case-sensitive comparison against GOOSE_MODEL from config.yaml, which is stored in lowercase. This causes the lookup to fail, silently falling back to the default 128_000 context limit.

Root cause

Two locations that disagree on normalization:

  1. create_custom_provider / update_custom_provider (declarative_providers.rs) — saves the model name without normalization:

    // Line ~217 (create) and ~266 (update)
    .map(|name| ModelInfo::new(name, 128000))
  2. normalize_model_config (provider_registry.rs) — performs a strict equality check:

    if let Some(info) = self.metadata.known_models
        .iter()
        .find(|m| m.name == model.model_name && m.context_limit > 0)
    {
        model.context_limit = Some(info.context_limit);
    }

    model.model_name comes from ModelConfig::new()GOOSE_MODEL in config.yaml, which is lowercased. But m.name in known_models retains the original case from the JSON config.

Impact

Custom provider models with uppercase letters in their name (e.g. GLM-5.1, Qwen3-Coder-480B) will always use the default 128k context limit, ignoring the context_limit value set in their JSON config file.

Suggested fix

Add case-insensitive comparison in normalize_model_config:

.find(|m| m.name.to_lowercase() == model.model_name.to_lowercase() && m.context_limit > 0)

Or alternatively, normalize the model name to lowercase in create_custom_provider / update_custom_provider when writing the JSON config.

Workaround

Manually edit the custom provider JSON file (~/.config/goose/custom_providers/<provider>.json) to use the exact same case as GOOSE_MODEL in config.yaml (typically lowercase).

Environment

  • goose version: 1.31.1
  • OS: Debian 12

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