{"record":{"id":"751e3af1e0906627","repo":"zed-industries/zed","slug":"model-not-found","errorCode":null,"errorMessage":"Model not found","messagePattern":"Model not found","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/agent/src/agent.rs","lineNumber":2569,"sourceCode":"\nimpl acp_thread::AgentModelSelector for NativeAgentModelSelector {\n    fn list_models(&self, cx: &mut App) -> Task<Result<acp_thread::AgentModelList>> {\n        log::debug!(\"NativeAgentConnection::list_models called\");\n        let list = self.connection.0.read(cx).models.model_list.clone();\n        Task::ready(if list.is_empty() {\n            Err(anyhow::anyhow!(\"No models available\"))\n        } else {\n            Ok(list)\n        })\n    }\n\n    fn select_model(&self, model_id: AgentModelId, cx: &mut App) -> Task<Result<()>> {\n        log::debug!(\n            \"Setting model for session {}: {}\",\n            self.session_id,\n            model_id\n        );\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\n        let Some(model) = self.connection.0.read(cx).models.model_from_id(&model_id) else {\n            return Task::ready(Err(anyhow!(\"Invalid model ID {}\", model_id)));\n        };\n\n        let favorite = agent_settings::AgentSettings::get_global(cx)\n            .favorite_models\n            .iter()\n            .find(|favorite| {","sourceCodeStart":2551,"sourceCodeEnd":2587,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/agent/src/agent.rs#L2551-L2587","documentation":"Returned by selected_model when the agent session's thread entity currently reports no model (thread.read(cx).model() is None), e.g. the model setting was cleared or not yet assigned. The task resolves immediately with this sentinel error rather than a real model info value.","triggerScenarios":"Thrown at crates/agent/src/agent.rs:2532 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Select a model for the thread before querying the selected model","Configure a default model in agent settings so threads start with one","Handle this error in the client by prompting the user to choose a model"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}