BoundaryML/baml · error

Execution Node out of bounds (render prompt)

Error message

Execution Node out of bounds (render prompt): {} >= {} for client {}

What it means

render_prompt_impl resolves the client's orchestrator strategy into a list of execution nodes, then indexes into that list with node_index. When the requested node index equals or exceeds the number of selected nodes, rendering cannot pick a prompt and the runtime errors out naming the index, list length, and client spec.

Solutions

  1. Pass None (or 0) for node_index to use the first/default execution node
  2. Clamp node_index to selected.len() - 1, or inspect the client's strategy to know how many nodes exist
  3. Update client retry/fallback config so it defines as many nodes as your code requests
  4. Fix callers (e.g. render_prompt wrappers) that pass a stale index from a previous client configuration

Example fix

// before
rt.render_prompt(&ctx, &client, &fn_name, &args, Some(2))?; // only 1 node
// after
rt.render_prompt(&ctx, &client, &fn_name, &args, None)?;
Defensive patterns

Strategy: validation

Validate before calling

if let Some(idx) = node_index {
    if idx >= num_execution_nodes(client) {
        return Err(format!("node_index {} out of range for client", idx));
    }
}

Prevention

When it happens

Trigger: Calling render_prompt with Some(node_index) that is beyond the orchestrator's selected node count — e.g. requesting node 2 of a fallback/orchestra chain that only resolved to 1 node, or a single client producing just one node while a larger index is passed.

Common situations: Retrying/stepping through fallback chains with stale node indices; clients whose retry/fallback policy changed so fewer nodes exist than the caller expects; hardcoded indices in custom orchestration code.

Related errors


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

Appendix: source

Thrown at engine/baml-runtime/src/lib.rs:726

            function_params,
            params,
            internal_baml_core::ir::ArgCoercer {
                span_path: None,
                allow_implicit_cast_to_string: false,
                skip_assert_eval: false,
            },
        )?;

        let renderer = PromptRenderer::from_function(&func, self.ir(), ctx)?;

        let client_spec = renderer.client_spec();
        let client = self.get_llm_provider_impl(client_spec, ctx)?;
        let mut selected =
            client.iter_orchestrator(&mut Default::default(), Default::default(), ctx, self)?;
        let node_index = node_index.unwrap_or(0);

        if node_index >= selected.len() {
            return Err(anyhow::anyhow!(
                "Execution Node out of bounds (render prompt): {} >= {} for client {}",
                node_index,
                selected.len(),
                client_spec,
            ));
        }

        let baml_args =
            BamlValue::Map(baml_args.into_iter().map(|(k, v)| (k, v.value())).collect());
        let node = selected.swap_remove(node_index);
        node.provider
            .render_prompt(self.ir(), &renderer, ctx, &baml_args)
            .await
            .map(|prompt| (prompt, node.scope, node.provider.allowed_metadata().clone()))
    }

    pub fn llm_provider_from_function(
        &self,

View on GitHub (pinned to bd85ce9dee)