{"record":{"id":"30ae11dea2cd24c5","repo":"aaif-goose/goose","slug":"could-not-resolve-model-config-error","errorCode":null,"errorMessage":"Could not resolve model config: {error}","messagePattern":"Could not resolve model config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/goose/src/agents/agent.rs","lineNumber":1775,"sourceCode":"                        }\n                    }\n                    Ok(None) => {}\n                    Err(e) => tracing::warn!(\"Failed to generate session description: {}\", e),\n                }\n            });\n        }\n\n        let model_config = match entry_session.model_config {\n            Some(model_config) => model_config,\n            None => {\n                let provider_name = Config::global()\n                    .get_goose_provider()\n                    .map_err(|_| anyhow!(\"Could not resolve model config: missing provider\"))?;\n                let model_name = Config::global()\n                    .get_goose_model()\n                    .map_err(|_| anyhow!(\"Could not resolve model config: missing model\"))?;\n                crate::model_config::model_config_from_user_config(&provider_name, &model_name)\n                    .map_err(|error| anyhow!(\"Could not resolve model config: {error}\"))?\n            }\n        };\n\n        let context_limit = provider\n            .get_context_limit(&model_config)\n            .await\n            .unwrap_or_else(|_| model_config.context_limit());\n        let steer_queue = self.steer_queue(&session_id).await;\n        let machine = self.create_state_machine(\n            provider,\n            model_config,\n            context_limit,\n            session_config.max_turns,\n            cancel.clone(),\n            steer_queue,\n        );\n        let reply_span = tracing::Span::current();\n","sourceCodeStart":1757,"sourceCodeEnd":1793,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose/src/agents/agent.rs#L1757-L1793","documentation":"Reply-path final fallback: with provider and model names from global config, model_config_from_user_config still failed and its {error} is wrapped here. The payload names the actual failure — usually an unresolvable provider id or a malformed custom provider definition, since the names were present but couldn't be turned into a working ModelConfig.","triggerScenarios":"GOOSE_PROVIDER value doesn't match any built-in/configured provider; custom OpenAI-compatible provider entry in config.yaml is malformed; provider id requires a newer goose version.","commonSituations":"Typos or renamed provider ids across goose versions; copied config files referencing custom providers that aren't defined on this machine.","solutions":["Read the wrapped {error} — it states exactly why construction failed","Match the provider id against `goose configure` options","Fix or complete custom provider entries in config.yaml","Update goose so recently added providers resolve"],"exampleFix":"# before\nGOOSE_PROVIDER=anthropic-claude GOOSE_MODEL=claude-sonnet-4-5 goose session\nError: Could not resolve model config: ...\n\n# after\nGOOSE_PROVIDER=anthropic GOOSE_MODEL=claude-sonnet-4-5 goose session","handlingStrategy":"try-catch","validationCode":"let (p, m) = (\n    goose::config::Config::global().get_goose_provider()?,\n    goose::config::Config::global().get_goose_model()?,\n);\nif goose::model_config::model_config_from_user_config(&p, &m).is_err() {\n    anyhow::bail!(\"cannot build model config from {p}/{m} — check provider id\");\n}","typeGuard":"fn model_config_failed(e: &anyhow::Error) -> bool {\n    let s = e.to_string();\n    s.starts_with(\"Could not resolve model config\")\n        && !s.contains(\"missing provider\")\n        && !s.contains(\"missing model\")\n}","tryCatchPattern":"match agent.reply(msg, session_config, token).await {\n    Err(e) if model_config_failed(&e) => {\n        // provider id invalid; stop and reconfigure rather than retrying\n        anyhow::bail!(\"invalid provider/model config: {e}\");\n    }\n    other => other?,\n}","preventionTips":["Verify provider ids exist in the current goose version before deploying","Include a config smoke-test (build the ModelConfig) in startup health checks","Upgrade goose and provider CLIs together"],"tags":["rust","goose","provider","config","validation","reply"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}