{"record":{"id":"b79c46d4316565f6","repo":"zed-industries/zed","slug":"no-subagent-session-found-with-id-session-id","errorCode":null,"errorMessage":"No subagent session found with id {session_id}","messagePattern":"No subagent session found with id (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/agent.rs","lineNumber":3101,"sourceCode":"            session = parent_thread_entity.read(cx).id().to_string(),\n            subagent_session = session_id.to_string(),\n            depth,\n            is_resumed = false,\n        );\n\n        self.prompt_subagent(session_id, subagent_thread, acp_thread)\n    }\n\n    pub(crate) fn resume_subagent_thread(\n        &self,\n        session_id: acp::SessionId,\n        cx: &mut App,\n    ) -> Result<Rc<dyn SubagentHandle>> {\n        let (subagent_thread, acp_thread) = self.agent.update(cx, |agent, _cx| {\n            let session = agent\n                .sessions\n                .get(&session_id)\n                .ok_or_else(|| anyhow!(\"No subagent session found with id {session_id}\"))?;\n            anyhow::Ok((session.thread.clone(), session.acp_thread.clone()))\n        })??;\n\n        let depth = subagent_thread.read(cx).depth();\n\n        if let Some(parent_thread_entity) = self.thread.upgrade() {\n            telemetry::event!(\n                \"Subagent Started\",\n                session = parent_thread_entity.read(cx).id().to_string(),\n                subagent_session = session_id.to_string(),\n                depth,\n                is_resumed = true,\n            );\n        }\n\n        self.prompt_subagent(session_id, subagent_thread, acp_thread)\n    }\n","sourceCodeStart":3083,"sourceCodeEnd":3119,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/agent.rs#L3083-L3119","documentation":"resume_subagent_thread looks the id up in agent.sessions and fails when it is absent: the subagent session was either never created in this process or has already been closed.","triggerScenarios":"Calling resume_subagent with an id from a previous app run, from a different agent instance, or after the subagent finished and its session entry was removed.","commonSituations":"Persisted plans referencing subagent session ids after a restart; cross-workspace resume attempts; resuming already-completed subagents.","solutions":["Use create_subagent_thread to start a fresh subagent instead of resuming when the id is not from the current process.","Verify the id exists in the session list before attempting resume.","Persist enough context to recreate the subagent rather than relying on in-memory session continuity."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// only resume ids that still exist in this process\nlet resumable = session_ids_from_current_process.contains(&session_id);\nif !resumable {\n    // create a new subagent and re-feed context instead\n}","typeGuard":null,"tryCatchPattern":"match env.resume_subagent_thread(session_id.clone(), cx) {\n    Ok(handle) => handle,\n    Err(e) if e.to_string().contains(\"No subagent session found\") => {\n        env.create_subagent_thread(label, cx)? // fall back to fresh subagent\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Do not persist subagent session ids across restarts and assume they resume.","Track subagent ids from the same agent instance you resume them against."],"tags":["rust","zed","agent","subagent","resume","session"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}