BoundaryML/baml · warning
Operation cancelled: {message}
Error message
Operation cancelled: {message} What it means
BAML's LLMResponse::Cancelled variant is converted to this error when .content() is called on a cancelled LLM call. The runtime raises it when an orchestration attempt was aborted (e.g. due to a cancellation signal or a faster winning strategy) so the response has no content to return.
Source
Thrown at engine/baml-runtime/src/internal/llm_client/mod.rs:207
}
Self::InternalFailure(message) => write!(f, "Failed before LLM call: {message}"),
Self::Cancelled(message) => write!(f, "Operation cancelled: {message}"),
}
}
}
impl LLMResponse {
pub fn content(&self) -> Result<&str> {
match self {
Self::Success(response) => Ok(&response.content),
Self::LLMFailure(failure) => Err(anyhow::anyhow!("LLM call failed: {failure:?}")),
Self::UserFailure(message) => Err(anyhow::anyhow!(
"Failed before LLM call (user error): {message}"
)),
Self::InternalFailure(message) => {
Err(anyhow::anyhow!("Failed before LLM call: {message}"))
}
Self::Cancelled(message) => Err(anyhow::anyhow!("Operation cancelled: {message}")),
}
}
}
#[derive(Debug, Clone, Serialize, PartialEq)]
pub struct LLMErrorResponse {
pub client: String,
pub model: Option<String>,
pub prompt: RenderedPrompt,
pub request_options: BamlMap<String, serde_json::Value>,
#[cfg_attr(target_arch = "wasm32", serde(skip_serializing))]
pub start_time: web_time::SystemTime,
pub latency: web_time::Duration,
// Short error message
pub message: String,
pub code: ErrorCode,
View on GitHub (pinned to bd85ce9dee)
Solutions
- Treat this as an expected cancellation, not a bug: catch it and return/propagate the abort to your caller.
- Check for cancellation (request abort signal, tokio cancellation token) before starting or while awaiting BAML calls.
- If cancellations are unexpected, audit who is dropping/aborting the futures driving the orchestration.
- Use retry/orchestration fallback strategies so an aborted attempt falls back to another client.
Example fix
// before
let content = llm_response.content()?; // Operation cancelled: ...
// after
match llm_response {
LLMResponse::Cancelled(msg) => Err(MyError::Cancelled(msg)),
resp => Ok(resp.content()?),
} Defensive patterns
Strategy: try-catch
Type guard
fn is_cancelled(resp: &LLMResponse) -> bool {
matches!(resp, LLMResponse::Cancelled(_))
} Try / catch
match llm_response {
LLMResponse::Cancelled(msg) => return Err(AppError::ClientCancelled(msg)),
resp => Ok(resp.content()?),
} Prevention
- Propagate client disconnect/abort signals into your BAML call path so cancellation is handled at the boundary, not inside content().
- Avoid holding LLM results past request lifetime; process them before the abort can fire.
- Configure orchestration retries/fallbacks so an aborted attempt is retried when appropriate.
When it happens
Trigger: Calling .content() on an LLMResponse::Cancelled produced by the orchestrator's tokio::select! race branch (call.rs) when a cancel_future wins the select, e.g. client cancellation or an orchestration strategy abandoning a pending attempt.
Common situations: Users abort HTTP requests to a BAML-backed service; timeouts cancelling in-flight orchestrations; multi-strategy orchestration where a losing branch is discarded mid-call.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
Related errors
- AbortError: {detailed_message}
- Operation cancelled..
- -32800
- tests have not been collected for this build yet
- BAML engine is shutting down
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/88e184eda3d65902.
Report an issue: GitHub.