BoundaryML/baml · warning
Cancelled: {}
Error message
Cancelled: {} What it means
In run_test_with_expr_events, LLMResponse::Cancelled(e) is converted to an error with the prefix 'Cancelled: '. This occurs when the LLM call was aborted — e.g., a cancel tripwire fired or the caller dropped/cancelled the future — before a final response was obtained. It distinguishes deliberate cancellation from genuine provider failures.
Source
Thrown at engine/baml-runtime/src/lib.rs:1071
type_builder.as_ref(),
None,
env_vars.clone(),
)
.await;
let res = response_res?;
let (_, llm_resp, val) = res
.event_chain()
.iter()
.last()
.context("Expected non-empty event chain")?;
if let Some(expr_tx) = expr_tx {
expr_tx.unbounded_send(vec![]).unwrap();
}
let complete_resp = match llm_resp {
LLMResponse::Success(complete_llm_response) => Ok(complete_llm_response),
LLMResponse::InternalFailure(e) => Err(anyhow::anyhow!("{}", e)),
LLMResponse::UserFailure(e) => Err(anyhow::anyhow!("{}", e)),
LLMResponse::Cancelled(e) => Err(anyhow::anyhow!("Cancelled: {}", e)),
LLMResponse::LLMFailure(e) => Err(anyhow::anyhow!({
let scrubbed_opts =
crate::redaction::scrub_baml_options(&e.request_options, &env_vars, false);
format!(
"{} {}\n\nRequest options: {}",
e.code,
e.message,
serde_json::to_string(&scrubbed_opts).unwrap_or_default()
)
})),
}?;
let test_constraints_result = if constraints.is_empty() {
TestConstraintsResult::empty()
} else {
match val {
Some(Ok(value)) => {
let value_with_constraints = value.0.map_meta(|m| m.1.clone());
evaluate_test_constraints(View on GitHub (pinned to bd85ce9dee)
Solutions
- Remove the cancellation trigger or increase the timeout that cancelled the call
- Avoid dropping/aborting the future mid-call unless cancellation is intended
- Check that the cancel_tripwire/timeout configuration matches expected LLM latency
- Retry the test without concurrent cancellation
Example fix
// before let timeout = Duration::from_secs(1); // too short, call gets cancelled // after let timeout = Duration::from_secs(60);
Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure the cancel tripwire is not pre-armed
if cancel_tripwire.is_cancelled() {
return Err(anyhow!("tripwire already cancelled before test start"));
} Try / catch
match result {
Err(e) if e.to_string().starts_with("Cancelled:") => eprintln!("test was cancelled: {e}"),
other => other?,
} Prevention
- Set timeouts comfortably above expected LLM latency
- Don't abort test futures mid-call unless cancellation is intended
- Treat Cancelled as operational state, not a provider failure
When it happens
Trigger: Running an expr-function test while the cancellation token/tripwire is triggered (timeout, user abort, shutdown), so the runtime returns LLMResponse::Cancelled which the test harness surfaces as 'Cancelled: {reason}'.
Common situations: Test timeout hitting the cancel tripwire; Ctrl-C or task abort in the harness; a watchdog cancelling long-running LLM calls; nested runtimes shutting down streams.
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
- baml.panics.Cancelled
- {self}\n\nDetailed message: {detailed_message}
- Operation cancelled: {message}
- AbortError: {detailed_message}
- LLM client "{client_name}" timed out: {message}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/f1488f404835e741.
Report an issue: GitHub.