zed-industries/zed · error · anyhow::Error
Maximum subagent depth
Error message
Maximum subagent depth ({}) reached What it means
Guard in NativeThreadEnvironment::create_subagent_thread: the parent thread's nesting depth already equals the configured maximum, so creating another nested subagent is refused to prevent unbounded recursion (message includes the depth limit).
Solutions
- Do the remaining work in the current thread instead of spawning a deeper subagent
- Raise the configured subagent depth limit if deeper nesting is genuinely required
- Refactor the task so subagents are siblings rather than nested chains
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/agent/src/agent.rs:3097 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-08-20).
Data as JSON: /api/errors/067bc1f6288a345d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/agent/src/agent.rs:3121
}
fn watch(
&self,
_cx: &mut App,
) -> Option<async_channel::Receiver<acp_thread::SessionListUpdate>> {
Some(self.updates_rx.clone())
}
fn notify_refresh(&self) {
self.updates_tx
.try_send(acp_thread::SessionListUpdate::Refresh)
.ok();
}
fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
self
}
}
struct NativeAgentSessionTruncate {
thread: Entity<Thread>,
acp_thread: WeakEntity<AcpThread>,
}
impl acp_thread::AgentSessionTruncate for NativeAgentSessionTruncate {
fn run(
&self,
client_user_message_id: acp_thread::ClientUserMessageId,
cx: &mut App,
) -> Task<Result<()>> {
match self.thread.update(cx, |thread, cx| {
thread.truncate(client_user_message_id.clone(), cx)?;
Ok(thread.latest_token_usage())
}) {
Ok(usage) => {
self.acp_threadView on GitHub (pinned to 916fc2b8cb)