zed-industries/zed · error

Failed to send tool call authorization: {error}

Error message

Failed to send tool call authorization: {error}

What it means

Raised by Zed's agent thread when a tool-call authorization (permission) request cannot be delivered to the UI/client that owns the prompt. The request is sent over a channel inside a `RequestToolCallAuthorization` event; a send failure means the receiving half was already dropped. In practice the thread, agent panel, or ACP session went away between the tool call starting and the prompt being raised.

Source

Thrown at crates/agent/src/thread.rs:6442

        cx.spawn(async move |cx| {
            let (response_tx, mut response_rx) = oneshot::channel();
            if let Err(error) = stream
                .0
                .unbounded_send(Ok(ThreadEvent::ToolCallAuthorization(
                    ToolCallAuthorization {
                        tool_call: acp::ToolCallUpdate::new(
                            tool_call_id.clone(),
                            acp::ToolCallUpdateFields::new().title(title),
                        ),
                        options,
                        response: response_tx,
                        context,
                        kind: acp_thread::AuthorizationKind::PermissionGrant,
                    },
                )))
            {
                log::error!("Failed to send tool call authorization: {error}");
                return Err(anyhow!("Failed to send tool call authorization: {error}"));
            }

            let Some(check_settings) = check_settings else {
                let outcome = response_rx
                    .await
                    .map_err(|_| anyhow!("authorization channel closed"))?;
                ensure_tool_call_authorization_not_interrupted(&outcome)?;

                return Self::persist_permission_outcome(&outcome, fs, cx);
            };
            let Some((auto_allow_outcome, auto_deny_outcome)) = auto_resolution_outcomes else {
                return Err(anyhow!("missing auto-resolution outcomes"));
            };

            let (mut settings_tx, mut settings_rx) = watch::channel(());
            let _settings_subscription = cx.update(|cx| {
                cx.observe_global::<SettingsStore>(move |_cx| {
                    settings_tx.send(()).ok();

View on GitHub (pinned to bc538def45)

Solutions

  1. Treat the failed send as cancellation: abort the tool call and report 'permission prompt unavailable' instead of retrying the send.
  2. Verify a live consumer of `RequestToolCallAuthorization` events (agent panel / ACP bridge) exists before spawning permission-requiring tools.
  3. In tests, pump the event loop and answer `response_tx` so the channel always has a live receiver.
  4. Audit shutdown ordering so the thread is not dropped while tool tasks are still waiting on a prompt.
Defensive patterns

Strategy: try-catch

Validate before calling

// Before starting permission-requiring tools, confirm the thread's event loop is alive:
if !authorization_events_being_served(&thread, cx) {
    anyhow::bail!("agent thread is shutting down; skip the tool call");
}

Try / catch

match send_authorization_request(&thread, request).await {
    Ok(outcome) => handle(outcome),
    Err(err) if err.to_string().starts_with("Failed to send tool call authorization") => {
        // Prompt consumer is gone: treat as cancellation, not a crash.
        report_cancelled();
    }
    Err(err) => return Err(err),
}

Prevention

When it happens

Trigger: A permission-requiring tool runs while the event receiver is gone: the agent panel or window was closed, the run/thread was cancelled, the ACP client disconnected, or a test spawned the thread without anything polling its event stream. The `send(...)` on the authorization event channel returns Err and this branch fires.

Common situations: Pressing stop or closing the agent panel at the instant a prompt would appear; running the agent headlessly with no authorization UI attached; integration tests that tear down the app context before answering prompts.

Related errors


AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16). Data as JSON: /api/errors/e60bfbfed03acd6c. Report an issue: GitHub.