aaif-goose/goose · error

Failed to create model configuration: {e}

Error message

Failed to create model configuration: {e}

What it means

build_switched_model_config rebuilds a ModelConfig from user configuration for a provider/model pair when the user switches models (e.g. the /model command), carrying over temperature and toolshim settings. Any failure from model_config_from_user_config — unknown provider, unresolvable model, inconsistent config — is wrapped as 'Failed to create model configuration: {e}'.

Source

Thrown at crates/goose-cli/src/session/mod.rs:2756

        let minutes = total_secs / 60;
        let seconds = total_secs % 60;
        format!("{}m {:02}s", minutes, seconds)
    }
}

fn build_switched_model_config(
    provider_name: &str,
    model_name: &str,
    current_model_config: &goose_providers::model::ModelConfig,
) -> Result<goose_providers::model::ModelConfig> {
    goose::model_config::model_config_from_user_config(provider_name, model_name)
        .map(|config| {
            config
                .with_temperature(current_model_config.temperature)
                .with_toolshim(current_model_config.toolshim)
                .with_toolshim_model(current_model_config.toolshim_model.clone())
        })
        .map_err(|e| anyhow::anyhow!("Failed to create model configuration: {e}"))
}

#[cfg(test)]
mod tests {
    use super::*;
    use goose::agents::extension::Envs;
    use goose::config::ExtensionConfig;
    use std::collections::HashMap;
    use std::time::Duration;
    use test_case::test_case;

    #[test]
    fn planner_classification_excludes_user_only_content() {
        use rmcp::model::{Annotations, Role, TextContent};

        let user_only = TextContent::new("user-only plan")
            .with_annotations(Annotations::default().with_audience(vec![Role::User]));
        let assistant_only = TextContent::new("agent classification text")

View on GitHub (pinned to 3810898a74)

Solutions

  1. Run goose configure and re-select a valid provider and model
  2. Verify the exact provider and model ids before switching (goose configure -> view)
  3. Keep GOOSE_PROVIDER and GOOSE_MODEL consistent when set via environment

Example fix

# before
/model openai/gpt-9-turbo      # unknown model id
# after
/model openai/gpt-4o
Defensive patterns

Strategy: validation

Validate before calling

let known = goose::model_config::known_models(); // or list from configure
assert!(
    known.contains(&(provider_name, model_name)),
    "unknown provider/model pair: {}/{}",
    provider_name,
    model_name
);

Try / catch

if let Err(e) = switch_model(&provider, &model).await {
    if e.to_string().contains("Failed to create model configuration") {
        eprintln!("run 'goose configure' to pick a valid provider/model");
    }
    return Err(e);
}

Prevention

When it happens

Trigger: Switching to a provider/model goose cannot resolve from configuration: /model someprovider/nonexistent-model, or a provider whose entries are missing after manual config edits.

Common situations: Typos in model ids; provider never configured via goose configure; hand-edited config files left inconsistent; env overrides (GOOSE_PROVIDER/GOOSE_MODEL) conflicting.

Related errors


AI-assisted analysis of aaif-goose/goose@3810898a74 (2026-08-16). Data as JSON: /api/errors/70565b263ca3eab8. Report an issue: GitHub.