zed-industries/zed · error
no thread found with ID: {id:?}
Error message
no thread found with ID: {id:?} What it means
Agent::load_thread connects to the threads database (ThreadsDatabase::connect) and loads by acp::SessionId; a None result is wrapped with 'no thread found with ID: {id:?}'. The session id must exist as a persisted row in the local threads database for the current data dir/profile.
Source
Thrown at crates/agent/src/agent.rs:1575
}
Some(command)
});
std::iter::once(compact_command)
.chain(mcp_commands)
.collect()
}
pub fn load_thread(
&mut self,
id: acp::SessionId,
project: Entity<Project>,
cx: &mut Context<Self>,
) -> Task<Result<Entity<Thread>>> {
let database_future = ThreadsDatabase::connect(cx);
cx.spawn(async move |this, cx| {
let database = database_future.await.map_err(|err| anyhow!(err))?;
let db_thread = database
.load_thread(id.clone())
.await?
.with_context(|| format!("no thread found with ID: {id:?}"))?;
this.update(cx, |this, cx| {
let project_id = this.get_or_create_project_state(&project, cx);
let project_state = this
.projects
.get(&project_id)
.context("project state not found")?;
let summarization_model = LanguageModelRegistry::read_global(cx)
.thread_summary_model(cx)
.map(|c| c.model);
Ok(cx.new(|cx| {
let mut thread = Thread::from_db(
id.clone(),View on GitHub (pinned to bc538def45)
Solutions
- Enumerate sessions from the database first and confirm the id exists before loading
- If the DB is legitimately fresh, create a new session instead of loading the old id
- If sessions should exist, check for DB corruption/migration errors in logs and back up the DB file before further writes
Defensive patterns
Strategy: validation
Validate before calling
// List persisted sessions before loading a specific id
let database = ThreadsDatabase::connect(cx).await?;
let known: HashSet<_> = database.list_thread_ids().await?.into_iter().collect();
if !known.contains(&session_id) {
return create_new_session(); // do not call load_thread with a dead id
} Try / catch
let thread = agent.load_thread(id.clone(), project, cx).await;
match thread {
Err(error) if error.to_string().contains("no thread found") => {
// Stale id (deleted session / fresh DB): create a new one instead.
create_session_and_inform_client().await
}
other => other,
} Prevention
- Treat load-by-id as fallible; always pair it with a create-on-missing path
- Do not carry session ids across profile/data-dir switches or DB resets
- Back up the threads database before experiments that touch migrations
When it happens
Trigger: load_thread(id) for a session that was deleted, belongs to another profile/machine/data dir, or when the threads DB was reset or failed to migrate — load_thread returns Option::None and the context is attached.
Common situations: Client reconnects with a stale session list after the DB was wiped or ZED_DATA_DIR changed; restoring a session id from a backup into a fresh install; DB migration dropped rows; session deleted in another window concurrently.
Related errors
- message not found
- Project state not found for session
- Session not found
- output token limit reached
- not supported
AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16).
Data as JSON: /api/errors/fe6c77565526b27a.
Report an issue: GitHub.