zed-industries/zed · error
Model not found
Error message
Model not found
What it means
The session exists, but `thread.read(cx).model()` returns None: the Thread has no language model assigned. selected_model reports this instead of guessing, because mapping to AgentModelInfo requires a concrete model instance.
Source
Thrown at crates/agent/src/agent.rs:2489
},
);
Task::ready(Ok(()))
}
fn selected_model(&self, cx: &mut App) -> Task<Result<acp_thread::AgentModelInfo>> {
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) = thread.read(cx).model() else {
return Task::ready(Err(anyhow!("Model not found")));
};
let Some(provider) = LanguageModelRegistry::read_global(cx).provider(&model.provider_id())
else {
return Task::ready(Err(anyhow!("Provider not found")));
};
Task::ready(Ok(LanguageModels::map_language_model_to_info(
model, &provider,
)))
}
fn favorite_model_ids(&self, cx: &mut App) -> HashSet<AgentModelId> {
agent_settings::AgentSettings::get_global(cx)
.favorite_model_ids()
.into_iter()
.map(AgentModelId::from)
.collect()
}
View on GitHub (pinned to bc538def45)
Solutions
- Set a default model in AgentSettings (or pass the model explicitly when creating the thread) so every Thread starts with one.
- Re-query after settings and the model registry settle — the model is assigned at construction or when explicitly set.
- Surface a 'pick a model' prompt instead of showing the raw error to the user.
Example fix
// before
let info = connection.selected_model(cx).await?; // fails with "Model not found"
// after
if thread.read(cx).model().is_none() {
agent_settings::AgentSettings::get_global(cx)
.set_default_model(Some(default_model_id), cx);
}
let info = connection.selected_model(cx).await?; Defensive patterns
Strategy: validation
Validate before calling
// before requesting model info, ensure the thread has a model
let has_model = thread.read(cx).model().is_some();
if !has_model {
// set default model or prompt the user to pick one
} Type guard
fn thread_has_model(thread: &Entity<Thread>, cx: &App) -> bool {
thread.read(cx).model().is_some()
} Prevention
- Configure a default model in AgentSettings so new threads always start with one.
- After creating a session programmatically, set its model before issuing model-dependent requests.
When it happens
Trigger: Querying the model immediately after session creation before a default model has been assigned; the user has no default model configured in AgentSettings and none was passed at thread creation; the model was cleared when its provider went away.
Common situations: Fresh installs with no default_model in agent settings; upgrades that reset model configuration; tests that create threads without setting a model.
Related errors
AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16).
Data as JSON: /api/errors/751e3af1e0906627.
Report an issue: GitHub.