{"record":{"id":"e2e7e3c61ef9455a","repo":"zed-industries/zed","slug":"user-canceled","errorCode":null,"errorMessage":"User canceled","messagePattern":"User canceled","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/agent/src/agent.rs","lineNumber":3419,"sourceCode":"                        .last_message()\n                        .and_then(|message| {\n                            let content = message.as_agent_message()?\n                                .content\n                                .iter()\n                                .filter_map(|c| match c {\n                                    AgentMessageContent::Text(text) => Some(text.as_str()),\n                                    _ => None,\n                                })\n                                .join(\"\\n\\n\");\n                            if content.is_empty() {\n                                None\n                            } else {\n                                Some( content)\n                            }\n                        })\n                        .context(\"No response from subagent\")\n                }),\n                SubagentPromptResult::Cancelled => Err(anyhow!(\"User canceled\")),\n                SubagentPromptResult::Error(message) => Err(anyhow!(\"{message}\")),\n                SubagentPromptResult::ContextWindowWarning => {\n                    thread.update(cx, |thread, cx| thread.cancel(cx)).await;\n                    Err(anyhow!(\n                        \"The agent is nearing the end of its context window and has been \\\n                         stopped. You can prompt the thread again to have the agent wrap up \\\n                         or hand off its work.\"\n                    ))\n                }\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            result","sourceCodeStart":3401,"sourceCodeEnd":3437,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/agent.rs#L3401-L3437","documentation":"SubagentPromptResult::Cancelled maps to this error: the user interrupted the subagent's run (stop button or cancellation propagated from the parent), so no result content is produced. It is a control-flow outcome, not a defect.","triggerScenarios":"The user presses stop while a subagent is running; the parent thread is cancelled and cancellation reaches the subagent's prompt.","commonSituations":"Any user abort of a long-running subagent task; closing the parent run mid-subagent.","solutions":["Handle this error as 'cancelled' in the UI (show a stopped state) rather than as a failure.","Do not retry automatically — the user chose to stop.","Distinguish it from SubagentPromptResult::Error when presenting results."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match subagent_prompt_result {\n    Err(e) if e.to_string() == \"User canceled\" => {\n        // user abort: show stopped state, no retry\n    }\n    Err(e) => return Err(e),\n    Ok(output) => { /* use output */ }\n}","preventionTips":["Classify this exact message as a cancellation in error presentation code.","Never auto-retry after a user cancellation."],"tags":["rust","zed","agent","subagent","cancellation","user-abort"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}