{"record":{"id":"a54ae179578f2e33","repo":"zed-industries/zed","slug":"error-n-npartial-subagent-output-last-3-messages-up-to-4096","errorCode":null,"errorMessage":"{error:#}\\n\\nPartial subagent output (last 3 messages, up to 4096 characters each):\\n\\n{partial_output}","messagePattern":"(.+?)\\\\n\\\\nPartial subagent output \\(last 3 messages, up to 4096 characters each\\):\\\\n\\\\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/agent.rs","lineNumber":3578,"sourceCode":"                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    }\n\n    fn wait_for_exit(&self, cx: &AsyncApp) -> Result<Shared<Task<acp::TerminalExitStatus>>> {","sourceCodeStart":3560,"sourceCodeEnd":3596,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/agent/src/agent.rs#L3560-L3596","documentation":"This error appends the subagent's last 3 partial messages (each truncated to 4096 characters) to the original error when a subagent fails mid-turn. The agent keeps a rolling buffer of the subagent's partial output so failures are debuggable; this variant fires when that buffer is non-empty.","triggerScenarios":"Subagent thread result is Err, `discard_partial_output` is false, and `thread.subagent_partial_output()` returns a non-empty string — i.e. the model produced some messages before failing.","commonSituations":"A subagent fails partway through a long tool-using turn: context window exceeded mid-response, tool schema rejected by provider, or stream dropped after partial output.","solutions":["Read the appended partial output to see what the subagent was doing when it failed","Reduce the subagent's task scope or max tokens to avoid mid-turn truncation","Check the provider error at the top of the chain (before the 'Partial subagent output' section) for the root cause","Retry the subagent with a smaller or more focused prompt"],"exampleFix":"// before\nanyhow!(\"{error:#}\\n\\nPartial subagent output...{partial_output}\")\n// after\nanyhow!(\"{error:#}\\n\\nPartial subagent output (last 3 messages):\\n\\n{partial_output}\").context(\"subagent failed\")","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn failure_has_partial_output(error: &str) -> bool { error.contains(\"Partial subagent output\") }","tryCatchPattern":"if let Err(error) = result {\n    let (root, partial) = error.to_string().split_once(\"\\n\\nPartial subagent output\")\n        .map_or((error.to_string().as_str(), \"\"), |(r, p)| (r, p));\n    eprintln!(\"root cause: {root}\");\n}","preventionTips":["Keep subagent tasks short enough to finish within token limits","Cap subagent message history before it hits context limits","Parse the root cause before the partial-output section when handling programmatically"],"tags":["subagent","diagnostics","partial-output"],"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"}