{"record":{"id":"9c658fdd7a9fc19c","repo":"aaif-goose/goose","slug":"could-not-resolve-model-config-missing-provider","errorCode":null,"errorMessage":"Could not resolve model config: missing provider","messagePattern":"Could not resolve model config: missing provider","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/goose/src/agents/agent.rs","lineNumber":961,"sourceCode":"    pub async fn model_config_for_session(\n        &self,\n        session_id: &str,\n    ) -> Result<goose_providers::model::ModelConfig> {\n        if let Ok(session) = self\n            .config\n            .session_manager\n            .get_session(session_id, false)\n            .await\n        {\n            if let Some(model_config) = session.model_config {\n                return Ok(model_config);\n            }\n        }\n\n        let config = Config::global();\n        let provider_name = config\n            .get_goose_provider()\n            .map_err(|_| anyhow!(\"Could not resolve model config: missing provider\"))?;\n        let model_name = config\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(|e| anyhow!(\"Could not resolve model config: {e}\"))\n    }\n\n    /// When set, all stdio extensions will be started via `docker exec` in the specified container.\n    pub async fn set_container(&self, container: Option<Container>) {\n        *self.container.lock().await = container.clone();\n    }\n\n    pub async fn container(&self) -> Option<Container> {\n        self.container.lock().await.clone()\n    }\n\n    /// Check if a tool is a frontend tool\n    pub async fn is_frontend_tool(&self, name: &str) -> bool {","sourceCodeStart":943,"sourceCodeEnd":979,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose/src/agents/agent.rs#L943-L979","documentation":"Agent::model_config_for_session first tries the session's stored model_config; if absent it falls back to global config and requires Config::get_goose_provider() to succeed. This error means neither source has a provider: the session never persisted a model selection AND the global config (~/.config/goose/config.yaml or GOOSE_PROVIDER env) has no provider set.","triggerScenarios":"Calling model_config_for_session for a session created before any provider was chosen (session.model_config == None) while Config::global().get_goose_provider() returns Err — i.e. the GOOSE_PROVIDER key is missing from config.","commonSituations":"Fresh install that never ran `goose configure`; CI/headless environment without GOOSE_PROVIDER; a config file that was reset, moved, or is unreadable so keys parse as absent.","solutions":["Run `goose configure` and pick a provider/model","Export GOOSE_PROVIDER (and GOOSE_MODEL) in the environment","Once a model is selected in the session, it is persisted as session.model_config and the global fallback is no longer needed","Check ~/.config/goose/config.yaml exists and contains the keys (correct GOOSE_CONFIG path if overridden)"],"exampleFix":"# before\n$ goose session\nError: Could not resolve model config: missing provider\n\n# after\n$ export GOOSE_PROVIDER=anthropic GOOSE_MODEL=claude-sonnet-4-5\n$ goose session","handlingStrategy":"validation","validationCode":"let config = goose::config::Config::global();\nif config.get_goose_provider().is_err() {\n    anyhow::bail!(\"no provider configured: run `goose configure` or set GOOSE_PROVIDER\");\n}\n// safe to resolve a model config now","typeGuard":"fn missing_provider_config(e: &anyhow::Error) -> bool {\n    e.to_string().contains(\"missing provider\")\n}","tryCatchPattern":null,"preventionTips":["Run `goose configure` as part of setup automation","Persist a model choice into each session so the global fallback is never needed","Surface config problems at startup, not mid-reply"],"tags":["rust","goose","config","provider","model-selection"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}