{"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":"error","filePath":"crates/agent/src/agent.rs","lineNumber":3535,"sourceCode":"                        task.await\n                    } else {\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            let discard_partial_output = matches!(\n                &response,\n                Ok(Some(response)) if response.stop_reason == acp::StopReason::Cancelled\n                    || response.stop_reason == acp::StopReason::Refusal\n            );\n            let result = match response {\n                Ok(Some(response)) => match response.stop_reason {\n                    acp::StopReason::Cancelled => Err(anyhow!(\"User canceled\")),\n                    acp::StopReason::MaxTokens => Err(anyhow!(\"The agent reached the maximum number of tokens.\")),\n                    acp::StopReason::MaxTurnRequests => Err(anyhow!(\"The agent reached the maximum number of allowed requests between user turns. Try prompting again.\")),\n                    acp::StopReason::Refusal => Err(anyhow!(\"The agent refused to process that prompt. Try again.\")),\n                    _ => thread.read_with(cx, |thread, _cx| {\n                        thread\n                            .last_message()\n                            .and_then(|message| {\n                                let content = message.as_agent_message()?\n                                    .content\n                                    .iter()\n                                    .filter_map(|content| match content {\n                                        AgentMessageContent::Text(text) => Some(text.as_str()),\n                                        _ => None,\n                                    })\n                                    .join(\"\\n\\n\");\n                                if content.is_empty() {\n                                    None\n                                } else {","sourceCodeStart":3517,"sourceCodeEnd":3553,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/agent/src/agent.rs#L3517-L3553","documentation":"Sentinel error surfaced when a thread turn ends because the user canceled it (e.g. stop pressed) and the code extracts the agent's last message before cancellation; the context message 'User canceled' marks the turn as aborted.","triggerScenarios":"Thrown at crates/agent/src/agent.rs:3462 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The user cancelled the turn/operation; no recovery needed — wait for a new prompt","Avoid re-submitting the same prompt automatically, since the user explicitly stopped it","If cancellation was unintended (UI glitch), restart the turn manually"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}