Hmbown/CodeWhale · info

turn canceled

Error message

turn canceled

What it means

Raised when a runtime API turn reaches `TurnTerminalStatus::Canceled`. Like the failed/interrupted branches, it converts the terminal event to an error, using the event's error message if present or the literal "turn canceled" fallback. Canceled is distinct from interrupted: the turn was explicitly cancelled before completing.

Solutions

  1. If cancellation was intentional, handle this status gracefully in the caller instead of logging it as a failure.
  2. If not intentional, check for request timeouts or dropped connections between the client and the runtime.
  3. Inspect session logs to identify which component issued the cancel.
  4. Re-run the turn if the work was cancelled prematurely.
Defensive patterns

Strategy: try-catch

Try / catch

match run_turn(...).await {
    Err(e) if e.to_string().contains("turn canceled") => { /* expected during shutdown/abort */ }
    other => other?,
}

Prevention

When it happens

Trigger: A turn's event stream reports the Canceled terminal status — an explicit cancellation of the turn on the runtime side.

Common situations: Caller aborts the request (dropped future, ctrl-c, client disconnect); an upper layer cancels the runtime session; a cleanup/shutdown path cancelling in-flight turns.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/a7012688b03b8cbc. Report an issue: GitHub.

Appendix: source

Thrown at crates/app-server/src/lib.rs:1892

                "thread": Value::Null,
                "threads": [],
                "model": Value::Null,
                "model_provider": Value::Null,
                "cwd": Value::Null,
                "approval_policy": Value::Null,
                "sandbox": Value::Null,
                "events": [],
                "data": { "turn_id": turn_id },
            })),
            TurnTerminalStatus::Failed => Err(anyhow!(
                "{}",
                error.unwrap_or_else(|| "turn failed".to_string())
            )),
            TurnTerminalStatus::Interrupted => Err(anyhow!(
                "{}",
                error.unwrap_or_else(|| "turn interrupted".to_string())
            )),
            TurnTerminalStatus::Canceled => Err(anyhow!(
                "{}",
                error.unwrap_or_else(|| "turn canceled".to_string())
            )),
        }
    }

    async fn stream_turn_events<W: AsyncWrite + Unpin>(
        &self,
        thread_id: &str,
        turn_id: &str,
        response_id: &str,
        writer: &mut W,
        since_seq: u64,
        mut transcript: Option<&mut TurnTranscript>,
    ) -> Result<(u64, TurnTerminalStatus, Option<String>)> {
        let mut response = self
            .authed(self.client.get(format!(
                "{}/v1/threads/{thread_id}/events?since_seq={since_seq}",

View on GitHub (pinned to 73e0f67d83)