BoundaryML/baml · error

function '{function_name}' not found

Error message

function '{function_name}' not found

What it means

The async VM runtime resolves the requested function name against `resolved_function_names`; when absent, the call fails immediately with 'function not found' and a fresh FunctionCallId, before any tracing of an LLM call.

Source

Thrown at engine/baml-runtime/src/async_vm_runtime.rs:179

        &self,
        function_name: String,
        params: &BamlMap<String, BamlValue>,
        ctx: &RuntimeContextManager,
        tb: Option<&TypeBuilder>,
        cb: Option<&ClientRegistry>,
        collectors: Option<Vec<Arc<Collector>>>,
        env_vars: HashMap<String, String>,
        tags: Option<&HashMap<String, String>>,
        cancel_tripwire: Arc<TripWire>,
        watch_handler: Option<SharedWatchHandler>,
    ) -> (anyhow::Result<FunctionResult>, FunctionCallId) {
        // Find the function.
        let Some((function_index, function_kind)) =
            self.program.resolved_function_names.get(&function_name)
        else {
            // TODO: We don't have an ID here! We can't call tracer here for llm functions here.
            return (
                Err(anyhow!("function '{function_name}' not found")),
                FunctionCallId::new(),
            );
        };

        // If we're not running an expression function, then just delegate the
        // call to the LLM runtime.
        if matches!(function_kind, FunctionKind::Llm) {
            return self
                .llm_runtime
                .call_function(
                    function_name,
                    params,
                    ctx,
                    tb,
                    cb,
                    collectors,
                    env_vars,
                    tags,

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Check the function name spelling against your .baml definitions.
  2. Rebuild/reload the VM program so resolved_function_names is up to date.
  3. Confirm the function is declared as a top-level function in the loaded project.

Example fix

// before
vm.call_function("extract_info")
// after
vm.call_function("ExtractInfo")
Defensive patterns

Strategy: validation

Validate before calling

if (!program.resolved_function_names.has(functionName)) {
  throw new Error(`function '${functionName}' not found in program`);
}

Prevention

When it happens

Trigger: call_function (via call_function_sync) with a function_name not present in program.resolved_function_names.

Common situations: Calling a function that exists only as an expression function but isn't in the resolved LLM-function map, stale program after edits, or misspelled names.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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