zed-industries/zed · error · anyhow::Error
Subagent session {session_id} was released
Error message
Subagent session {session_id} was released What it means
Guard in resume_subagent_thread: the requested acp::SessionId is not present in the agent's live sessions map. This happens when the subagent session was already released (dropped after its run finished), or the id was never registered by spawn/prompt_subagent, so there is no subagent thread to resume and the lookup fails with a released-session error.
Source
Thrown at crates/agent/src/agent.rs:3254
);
self.prompt_subagent(session_id, subagent_thread, acp_thread)
}
pub(crate) fn resume_subagent_thread(
&self,
session_id: acp::SessionId,
cx: &mut App,
) -> Result<Rc<dyn SubagentHandle>> {
let (subagent_thread, acp_thread) = self.agent.update(cx, |agent, _cx| {
let session = agent
.sessions
.get(&session_id)
.ok_or_else(|| anyhow!("No subagent session found with id {session_id}"))?;
let acp_thread = session
.acp_thread
.upgrade()
.ok_or_else(|| anyhow!("Subagent session {session_id} was released"))?;
anyhow::Ok((session.thread.clone(), acp_thread))
})??;
let depth = subagent_thread.read(cx).depth();
if let Some(parent_thread_entity) = self.thread.upgrade() {
telemetry::event!(
"Subagent Started",
session = parent_thread_entity.read(cx).id().to_string(),
subagent_session = session_id.to_string(),
depth,
is_resumed = true,
);
}
self.prompt_subagent(session_id, subagent_thread, acp_thread)
}
View on GitHub (pinned to 9d272b0363)
Solutions
- Check whether the subagent finished and its session was cleaned up before requesting a resume; spawn a new subagent session instead of resuming a released one
- Verify the session id passed in matches the id returned when the subagent was originally created
- Retain the subagent session in the sessions map for as long as resume operations remain possible, or store enough state to re-create it
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/agent/src/agent.rs:3254 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-09-05).
Data as JSON: /api/errors/5f2bb88b24719aa3.
Report an issue: GitHub.