{"record":{"id":"5c71c78cb56a708a","repo":"zed-industries/zed","slug":"error-agent","errorCode":null,"errorMessage":"{error:#}","messagePattern":"\\{error:#\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/agent.rs","lineNumber":3576,"sourceCode":"                    }),\n                },\n                Ok(None) => Err(anyhow!(\"No response from the agent. You can try messaging again.\")),\n                Err(error) => Err(error),\n            };\n\n            parent_thread\n                .update(cx, |parent_thread, cx| {\n                    parent_thread.unregister_running_subagent(&subagent_session_id, cx)\n                })\n                .ok();\n\n            if discard_partial_output {\n                result\n            } else {\n                result.map_err(|error| {\n                    let partial_output = thread.read_with(cx, |thread, _| thread.subagent_partial_output());\n                    if partial_output.is_empty() {\n                        anyhow!(\"{error:#}\")\n                    } else {\n                        anyhow!(\"{error:#}\\n\\nPartial subagent output (last 3 messages, up to 4096 characters each):\\n\\n{partial_output}\")\n                    }\n                })\n            }\n        })\n    }\n}\n\npub struct AcpTerminalHandle {\n    terminal: Entity<acp_thread::Terminal>,\n    _drop_tx: Option<oneshot::Sender<()>>,\n}\n\nimpl TerminalHandle for AcpTerminalHandle {\n    fn id(&self, cx: &AsyncApp) -> Result<acp::TerminalId> {\n        Ok(self.terminal.read_with(cx, |term, _cx| term.id().clone()))\n    }","sourceCodeStart":3558,"sourceCodeEnd":3594,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/agent/src/agent.rs#L3558-L3594","documentation":"This error string is the plain `{error:#}` formatting of any error returned by the subagent thread when partial output exists handling is bypassed or the error is re-raised without augmentation. It propagates the original error chain (via anyhow's alternate formatting, including causes) to the caller of the subagent flow.","triggerScenarios":"The subagent thread's result is an Err and the error is formatted with `{error:#}` — either because `discard_partial_output` is true or because partial output was empty.","commonSituations":"Provider authentication failures, rate-limit responses, or malformed tool calls inside the subagent turn abort the thread and bubble up through this formatting.","solutions":["Read the full anyhow chain in the message to identify the root cause","Fix the underlying provider/config issue indicated by the root cause","Enable partial-output capture (discard_partial_output = false) to get debugging context on failure","Retry if the cause is a transient network or provider error"],"exampleFix":"// before\nanyhow!(\"{error:#}\")\n// after\nanyhow!(\"subagent task failed: {error:#}\")","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let output = subagent_task.await.map_err(|error| {\n    log::error!(\"subagent error chain: {error:?}\");\n    error\n})?;","preventionTips":["Keep anyhow contexts attached so the {error:#} chain is informative","Log the full {error:?} chain (with backtrace) on failure","Prefer discard_partial_output=false when debugging"],"tags":["error-propagation","anyhow","subagent"],"backgroundTag":"upstream-api-error","analyzedSha":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-09-19T19:09:50.599Z","contentChangedAt":"2026-09-19T19:09:50.599Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}