zed-industries/zed · error

User canceled

Error message

User canceled

What it means

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.

Solutions

  1. The user cancelled the turn/operation; no recovery needed — wait for a new prompt
  2. Avoid re-submitting the same prompt automatically, since the user explicitly stopped it
  3. If cancellation was unintended (UI glitch), restart the turn manually
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/agent/src/agent.rs:3462 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-09-19). Data as JSON: /api/errors/e2e7e3c61ef9455a. Report an issue: GitHub.

Appendix: source

Thrown at crates/agent/src/agent.rs:3535

                        task.await
                    } else {
                        thread.update(cx, |thread, cx| thread.cancel(cx)).await;
                        Err(anyhow!(
                            "The agent is nearing the end of its context window and has been \
                             stopped. You can prompt the thread again to have the agent wrap up \
                             or hand off its work."
                        ))
                    }
                }
            };
            let discard_partial_output = matches!(
                &response,
                Ok(Some(response)) if response.stop_reason == acp::StopReason::Cancelled
                    || response.stop_reason == acp::StopReason::Refusal
            );
            let result = match response {
                Ok(Some(response)) => match response.stop_reason {
                    acp::StopReason::Cancelled => Err(anyhow!("User canceled")),
                    acp::StopReason::MaxTokens => Err(anyhow!("The agent reached the maximum number of tokens.")),
                    acp::StopReason::MaxTurnRequests => Err(anyhow!("The agent reached the maximum number of allowed requests between user turns. Try prompting again.")),
                    acp::StopReason::Refusal => Err(anyhow!("The agent refused to process that prompt. Try again.")),
                    _ => thread.read_with(cx, |thread, _cx| {
                        thread
                            .last_message()
                            .and_then(|message| {
                                let content = message.as_agent_message()?
                                    .content
                                    .iter()
                                    .filter_map(|content| match content {
                                        AgentMessageContent::Text(text) => Some(text.as_str()),
                                        _ => None,
                                    })
                                    .join("\n\n");
                                if content.is_empty() {
                                    None
                                } else {

View on GitHub (pinned to 916fc2b8cb)