{"record":{"id":"067bc1f6288a345d","repo":"zed-industries/zed","slug":"maximum-subagent-depth-reached","errorCode":null,"errorMessage":"Maximum subagent depth ({}) reached","messagePattern":"Maximum subagent depth \\((.+?)\\) reached","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/agent/src/agent.rs","lineNumber":3121,"sourceCode":"    }\n\n    fn watch(\n        &self,\n        _cx: &mut App,\n    ) -> Option<async_channel::Receiver<acp_thread::SessionListUpdate>> {\n        Some(self.updates_rx.clone())\n    }\n\n    fn notify_refresh(&self) {\n        self.updates_tx\n            .try_send(acp_thread::SessionListUpdate::Refresh)\n            .ok();\n    }\n\n    fn into_any(self: Rc<Self>) -> Rc<dyn Any> {\n        self\n    }\n}\n\nstruct NativeAgentSessionTruncate {\n    thread: Entity<Thread>,\n    acp_thread: WeakEntity<AcpThread>,\n}\n\nimpl acp_thread::AgentSessionTruncate for NativeAgentSessionTruncate {\n    fn run(\n        &self,\n        client_user_message_id: acp_thread::ClientUserMessageId,\n        cx: &mut App,\n    ) -> Task<Result<()>> {\n        match self.thread.update(cx, |thread, cx| {\n            thread.truncate(client_user_message_id.clone(), cx)?;\n            Ok(thread.latest_token_usage())\n        }) {\n            Ok(usage) => {\n                self.acp_thread","sourceCodeStart":3103,"sourceCodeEnd":3139,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/agent/src/agent.rs#L3103-L3139","documentation":"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).","triggerScenarios":"Thrown at crates/agent/src/agent.rs:3097 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}