BoundaryML/baml · error · anyhow::Error

No events in the chain

Error message

No events in the chain

What it means

ResponseChain::new_chain validates that the orchestration event chain passed to it contains at least one event; an empty Vec is rejected because a chain with no events cannot produce content, timing, or usage information. This is an input-validation guard on a public constructor.

Solutions

  1. Check that the events/chain vector is non-empty before calling new_chain, and return a more meaningful error upstream if it is.
  2. Fix the orchestration logic so at least one LLM response (success or failure) is always recorded.
  3. If a chain can legitimately be empty in your flow, handle that case before constructing a ResponseChain.

Example fix

// before
let chain = ResponseChain::new_chain(events)?; // events may be empty

// after
if events.is_empty() {
    anyhow::bail!("Orchestration produced no LLM events");
}
let chain = ResponseChain::new_chain(events)?;
Defensive patterns

Strategy: validation

Validate before calling

if events.is_empty() {
    anyhow::bail!("no LLM events recorded; cannot build response chain");
}
let chain = ResponseChain::new_chain(events)?;

Prevention

When it happens

Trigger: Calling ResponseChain::new_chain(vec![]) or equivalent with an empty list of (scope, llm_response, result) tuples, e.g. when orchestration produced no LLM calls at all before building the response chain.

Common situations: Retry/orchestration logic that filters out all failed attempts and then builds a chain from the (now empty) surviving list; streams where no LLM call was ever dispatched; custom orchestration code bypassing the normal runner.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/f795577f03a765ed. Report an issue: GitHub.

Appendix: source

Thrown at engine/baml-runtime/src/types/response.rs:82

    pub(crate) fn event_chain(
        &self,
    ) -> &Vec<(
        OrchestrationScope,
        LLMResponse,
        Option<Result<ResponseBamlValue>>,
    )> {
        &self.event_chain
    }

    pub fn new_chain(
        chain: Vec<(
            OrchestrationScope,
            LLMResponse,
            Option<Result<ResponseBamlValue>>,
        )>,
    ) -> Result<Self> {
        if chain.is_empty() {
            anyhow::bail!("No events in the chain");
        }

        Ok(Self { event_chain: chain })
    }

    pub fn content(&self) -> Result<&str> {
        self.llm_response().content()
    }

    pub fn llm_response(&self) -> &LLMResponse {
        &self.event_chain.last().unwrap().1
    }

    pub fn scope(&self) -> &OrchestrationScope {
        &self.event_chain.last().unwrap().0
    }

    pub fn parsed(&self) -> &Option<Result<ResponseBamlValue>> {

View on GitHub (pinned to bd85ce9dee)