{"record":{"id":"fe6c77565526b27a","repo":"zed-industries/zed","slug":"no-thread-found-with-id-id","errorCode":null,"errorMessage":"no thread found with ID: {id:?}","messagePattern":"no thread found with ID: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/agent.rs","lineNumber":1575,"sourceCode":"            }\n\n            Some(command)\n        });\n\n        std::iter::once(compact_command)\n            .chain(mcp_commands)\n            .collect()\n    }\n\n    pub fn load_thread(\n        &mut self,\n        id: acp::SessionId,\n        project: Entity<Project>,\n        cx: &mut Context<Self>,\n    ) -> Task<Result<Entity<Thread>>> {\n        let database_future = ThreadsDatabase::connect(cx);\n        cx.spawn(async move |this, cx| {\n            let database = database_future.await.map_err(|err| anyhow!(err))?;\n            let db_thread = database\n                .load_thread(id.clone())\n                .await?\n                .with_context(|| format!(\"no thread found with ID: {id:?}\"))?;\n\n            this.update(cx, |this, cx| {\n                let project_id = this.get_or_create_project_state(&project, cx);\n                let project_state = this\n                    .projects\n                    .get(&project_id)\n                    .context(\"project state not found\")?;\n                let summarization_model = LanguageModelRegistry::read_global(cx)\n                    .thread_summary_model(cx)\n                    .map(|c| c.model);\n\n                Ok(cx.new(|cx| {\n                    let mut thread = Thread::from_db(\n                        id.clone(),","sourceCodeStart":1557,"sourceCodeEnd":1593,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/agent.rs#L1557-L1593","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// List persisted sessions before loading a specific id\nlet database = ThreadsDatabase::connect(cx).await?;\nlet known: HashSet<_> = database.list_thread_ids().await?.into_iter().collect();\nif !known.contains(&session_id) {\n    return create_new_session(); // do not call load_thread with a dead id\n}","typeGuard":null,"tryCatchPattern":"let thread = agent.load_thread(id.clone(), project, cx).await;\nmatch thread {\n    Err(error) if error.to_string().contains(\"no thread found\") => {\n        // Stale id (deleted session / fresh DB): create a new one instead.\n        create_session_and_inform_client().await\n    }\n    other => other,\n}","preventionTips":["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"],"tags":["rust","zed","agent","database","session","acp"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}