BoundaryML/baml · error
LLM function not found: {}: {}
Error message
LLM function not found: {}: {} What it means
Before invoking a function through the async interpreter runtime, the runtime looks up the function name in the IR. If `find_function` fails, the name doesn't exist in the loaded BAML project, and the error includes the underlying lookup error detail.
Source
Thrown at engine/baml-runtime/src/async_interpreter_runtime.rs:265
move |fn_name: String,
args: Vec<BamlValue>,
watch_context: Option<WatchStreamContext>| {
let llm_runtime = Arc::clone(&llm_runtime_clone);
let ctx = ctx_clone.clone();
let tb = tb_clone.clone();
let cb = cb_clone.clone();
let env_vars = env_vars_clone.clone();
let cancel_tripwire = cancel_tripwire_clone.clone();
let watch_handler: SharedWatchHandler = Arc::clone(&watch_handler_for_llm);
let parent_fn = parent_function_name.clone();
let tags = tags_clone.clone();
#[cfg(not(target_arch = "wasm32"))]
let tokio_rt = tokio_runtime.clone();
async move {
// Find the LLM function to get parameter names
let llm_fn = llm_runtime.ir().find_function(&fn_name).map_err(|e| {
anyhow::anyhow!("LLM function not found: {}: {}", fn_name, e)
})?;
// Convert args to parameter map
let llm_params = args
.into_iter()
.zip(llm_fn.inputs().iter().map(|(name, _)| name.clone()))
.map(|(arg, param_name)| (param_name, arg))
.collect::<BamlMap<_, _>>();
// Check if we should use streaming with watch notifications
if let Some(watch_ctx) = watch_context {
// Use streaming with watch notifications
let tracer = llm_runtime.tracer_wrapper.get_or_create_tracer(&env_vars);
// Create RuntimeContext from RuntimeContextManager
let runtime_ctx = ctx.create_ctx(
tb.as_ref(),
cb.as_ref(),View on GitHub (pinned to bd85ce9dee)
Solutions
- Verify the function name matches a function declared in your .baml files (exact spelling/case).
- Ensure all .baml files containing the function are included in the runtime's loaded sources.
- Regenerate/reload the runtime after adding new functions so the IR is current.
Example fix
// before
runtime.call_function("ClassifgyIntent", args)
// after
runtime.call_function("ClassifyIntent", args) Defensive patterns
Strategy: validation
Validate before calling
// Rust: check before calling
if llm_runtime.ir().find_function(fn_name).is_err() {
eprintln!("function '{fn_name}' is not defined in loaded BAML sources");
return;
} Try / catch
match runtime.call_function(fn_name, args).await {
Ok(v) => v,
Err(e) if e.to_string().contains("LLM function not found") => {
eprintln!("Unknown function '{fn_name}': {e:#}");
Default::default()
}
Err(e) => return Err(e),
} Prevention
- Generate typed clients (baml CLI) so function names are checked at compile time.
- Keep generated runtime and .baml sources in sync.
When it happens
Trigger: call_function (via call_function_sync) with an fn_name that has no matching function in the compiled BAML IR.
Common situations: Typos in the function name, calling a function defined in a .baml file that wasn't loaded/compiled, or calling an expression function where only an LLM function lookup path is taken.
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
- function `{function_name}` not found
- function '{function_name}' not found
- failed to create engine: {e:?}
- failed to create engine: {e:?}
- function `{target_name}` not found
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/1222c75485d0fc15.
Report an issue: GitHub.