zed-industries/zed · error · anyhow::Error
Model not found
Error message
Model not found
What it means
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.
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/agent/src/agent.rs:2532 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-08-20).
Data as JSON: /api/errors/751e3af1e0906627.
Report an issue: GitHub.
Appendix: source
Thrown at crates/agent/src/agent.rs:2569
impl acp_thread::AgentModelSelector for NativeAgentModelSelector {
fn list_models(&self, cx: &mut App) -> Task<Result<acp_thread::AgentModelList>> {
log::debug!("NativeAgentConnection::list_models called");
let list = self.connection.0.read(cx).models.model_list.clone();
Task::ready(if list.is_empty() {
Err(anyhow::anyhow!("No models available"))
} else {
Ok(list)
})
}
fn select_model(&self, model_id: AgentModelId, cx: &mut App) -> Task<Result<()>> {
log::debug!(
"Setting model for session {}: {}",
self.session_id,
model_id
);
let Some(thread) = self
.connection
.0
.read(cx)
.sessions
.get(&self.session_id)
.map(|session| session.thread.clone())
else {
return Task::ready(Err(anyhow!("Session not found")));
};
let Some(model) = self.connection.0.read(cx).models.model_from_id(&model_id) else {
return Task::ready(Err(anyhow!("Invalid model ID {}", model_id)));
};
let favorite = agent_settings::AgentSettings::get_global(cx)
.favorite_models
.iter()
.find(|favorite| {View on GitHub (pinned to 916fc2b8cb)