{"record":{"id":"8868f8ca762938da","repo":"zed-industries/zed","slug":"provider-not-found","errorCode":null,"errorMessage":"Provider not found","messagePattern":"Provider not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/agent.rs","lineNumber":2493,"sourceCode":"    }\n\n    fn selected_model(&self, cx: &mut App) -> Task<Result<acp_thread::AgentModelInfo>> {\n        let Some(thread) = self\n            .connection\n            .0\n            .read(cx)\n            .sessions\n            .get(&self.session_id)\n            .map(|session| session.thread.clone())\n        else {\n            return Task::ready(Err(anyhow!(\"Session not found\")));\n        };\n        let Some(model) = thread.read(cx).model() else {\n            return Task::ready(Err(anyhow!(\"Model not found\")));\n        };\n        let Some(provider) = LanguageModelRegistry::read_global(cx).provider(&model.provider_id())\n        else {\n            return Task::ready(Err(anyhow!(\"Provider not found\")));\n        };\n        Task::ready(Ok(LanguageModels::map_language_model_to_info(\n            model, &provider,\n        )))\n    }\n\n    fn favorite_model_ids(&self, cx: &mut App) -> HashSet<AgentModelId> {\n        agent_settings::AgentSettings::get_global(cx)\n            .favorite_model_ids()\n            .into_iter()\n            .map(AgentModelId::from)\n            .collect()\n    }\n\n    fn toggle_favorite_model(&self, model_id: AgentModelId, should_be_favorite: bool, cx: &App) {\n        let selection = model_id_to_selection(&model_id, cx);\n        let fs = self.connection.0.read(cx).fs.clone();\n        update_settings_file(fs, cx, move |settings, _| {","sourceCodeStart":2475,"sourceCodeEnd":2511,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/agent.rs#L2475-L2511","documentation":"The thread has a model, but its provider_id is absent from the global LanguageModelRegistry. map_language_model_to_info needs the provider for metadata and display info, so the request fails even though the model id itself is known.","triggerScenarios":"The model references a provider that is disabled, signed out, not yet loaded, or removed; querying selected_model during startup before providers have registered in LanguageModelRegistry.","commonSituations":"Settings synced from another machine referencing an unavailable provider; signing out of hosted models; disabling a provider extension; init-time races before the registry populates.","solutions":["Enable or sign in to the provider the model belongs to, or switch the thread model to one from an active provider.","If it happens at startup, re-query after the registry finishes loading (observe LanguageModelRegistry for changes).","Prune stale model ids from settings (favorite_model_ids / default_model) that point at removed providers."],"exampleFix":"// before\nlet info = connection.selected_model(cx).await?; // \"Provider not found\"\n\n// after\nlet model = thread.read(cx).model().unwrap(); // guarded earlier\nlet provider_ok = LanguageModelRegistry::read_global(cx)\n    .provider(&model.provider_id())\n    .is_some();\nif !provider_ok { /* pick another model */ }","handlingStrategy":"validation","validationCode":"let Some(model) = thread.read(cx).model() else { return };\nlet provider_available = LanguageModelRegistry::read_global(cx)\n    .provider(&model.provider_id())\n    .is_some();\nif !provider_available {\n    // choose a model whose provider is registered, or defer until registry loads\n}","typeGuard":"fn provider_registered(provider_id: &LanguageModelProviderId, cx: &App) -> bool {\n    LanguageModelRegistry::read_global(cx).provider(provider_id).is_some()\n}","tryCatchPattern":null,"preventionTips":["Keep favorite/default model ids aligned with providers that are actually enabled.","During startup, wait for the language model registry to finish loading before querying model info."],"tags":["rust","zed","agent","provider","registry","configuration"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}