{"record":{"id":"1222c75485d0fc15","repo":"BoundaryML/baml","slug":"llm-function-not-found","errorCode":null,"errorMessage":"LLM function not found: {}: {}","messagePattern":"LLM function not found: (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/async_interpreter_runtime.rs","lineNumber":265,"sourceCode":"            move |fn_name: String,\n                  args: Vec<BamlValue>,\n                  watch_context: Option<WatchStreamContext>| {\n                let llm_runtime = Arc::clone(&llm_runtime_clone);\n                let ctx = ctx_clone.clone();\n                let tb = tb_clone.clone();\n                let cb = cb_clone.clone();\n                let env_vars = env_vars_clone.clone();\n                let cancel_tripwire = cancel_tripwire_clone.clone();\n                let watch_handler: SharedWatchHandler = Arc::clone(&watch_handler_for_llm);\n                let parent_fn = parent_function_name.clone();\n                let tags = tags_clone.clone();\n                #[cfg(not(target_arch = \"wasm32\"))]\n                let tokio_rt = tokio_runtime.clone();\n\n                async move {\n                    // Find the LLM function to get parameter names\n                    let llm_fn = llm_runtime.ir().find_function(&fn_name).map_err(|e| {\n                        anyhow::anyhow!(\"LLM function not found: {}: {}\", fn_name, e)\n                    })?;\n\n                    // Convert args to parameter map\n                    let llm_params = args\n                        .into_iter()\n                        .zip(llm_fn.inputs().iter().map(|(name, _)| name.clone()))\n                        .map(|(arg, param_name)| (param_name, arg))\n                        .collect::<BamlMap<_, _>>();\n\n                    // Check if we should use streaming with watch notifications\n                    if let Some(watch_ctx) = watch_context {\n                        // Use streaming with watch notifications\n                        let tracer = llm_runtime.tracer_wrapper.get_or_create_tracer(&env_vars);\n\n                        // Create RuntimeContext from RuntimeContextManager\n                        let runtime_ctx = ctx.create_ctx(\n                            tb.as_ref(),\n                            cb.as_ref(),","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/async_interpreter_runtime.rs#L247-L283","documentation":"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.","triggerScenarios":"call_function (via call_function_sync) with an fn_name that has no matching function in the compiled BAML IR.","commonSituations":"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.","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."],"exampleFix":"// before\nruntime.call_function(\"ClassifgyIntent\", args)\n// after\nruntime.call_function(\"ClassifyIntent\", args)","handlingStrategy":"validation","validationCode":"// Rust: check before calling\nif llm_runtime.ir().find_function(fn_name).is_err() {\n    eprintln!(\"function '{fn_name}' is not defined in loaded BAML sources\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"match runtime.call_function(fn_name, args).await {\n    Ok(v) => v,\n    Err(e) if e.to_string().contains(\"LLM function not found\") => {\n        eprintln!(\"Unknown function '{fn_name}': {e:#}\");\n        Default::default()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Generate typed clients (baml CLI) so function names are checked at compile time.","Keep generated runtime and .baml sources in sync."],"tags":["runtime","not-found","baml","function"],"backgroundTag":"resource-not-found","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}