{"record":{"id":"6280426023a19959","repo":"BoundaryML/baml","slug":"no-runtime-loaded-it-should-be-impossible-to-call-an-llm","errorCode":null,"errorMessage":"No runtime loaded, it should be impossible to call an LLM function","messagePattern":"No runtime loaded, it should be impossible to call an LLM function","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/cli/repl.rs","lineNumber":602,"sourceCode":"                                    output_tokens: resp.metadata.output_tokens,\n                                    total_tokens: resp.metadata.total_tokens,\n                                    cached_input_tokens: resp.metadata.cached_input_tokens,\n                                };\n                                let _ = tx.send(LlmStatusEvent::Finished(run_id, Some(usage)));\n                            } else {\n                                let _ = tx.send(LlmStatusEvent::Finished(run_id, None));\n                            }\n                        }\n                        match function_result.parsed() {\n                            Some(Ok(response_baml_value)) => Ok(response_baml_value\n                                .clone()\n                                .0\n                                .map_meta_owned(|_| (Span::fake(), None))),\n                            Some(Err(e)) => Err(anyhow!(\"Failed to parse function result: {}\", e)),\n                            None => Err(anyhow!(\"No parsed result available from function call\")),\n                        }\n                    }\n                    None => Err(anyhow!(\n                        \"No runtime loaded, it should be impossible to call an LLM function\"\n                    )),\n                }\n            }\n        };\n        // REPL watch handler: collect notifications\n        let watch_notifications = Arc::new(Mutex::new(Vec::new()));\n        let watch_notifications_clone = watch_notifications.clone();\n        let watch_handler = shared_handler(move |notification| {\n            watch_notifications_clone\n                .lock()\n                .unwrap()\n                .push(format!(\"{notification}\"));\n        });\n\n        let eval_result = interpret_thir(\n            \"repl\".to_string(),\n            thir.clone(),","sourceCodeStart":584,"sourceCodeEnd":620,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/cli/repl.rs#L584-L620","documentation":"Defensive invariant check: the REPL branch that invokes LLM functions should only be reachable when a runtime is loaded. If the runtime Option is None at call time, this error fires, signaling an internal state violation rather than a user-caused problem.","triggerScenarios":"parse_and_evaluate_baml_expression_with_status reaches the function-call arm while self.runtime is None — evaluating a function-call expression before any BAML sources were loaded.","commonSituations":"Starting the REPL and immediately calling a function without :load, a race where the runtime was reset mid-session, or a bug in runtime initialization.","solutions":["Load BAML sources first with :load <path-to-baml_src> before calling functions","Restart the REPL if a :reset or failed :load left the runtime unloaded","Check that the initial baml_src load succeeded (watch for earlier load errors)","File a bug if it occurs with a successfully loaded runtime"],"exampleFix":"// before (REPL input)\nMyFn(1)            // no sources loaded\n// after\n:load ./baml_src\nMyFn(1)","handlingStrategy":"validation","validationCode":"// Guard in embedding code before evaluating function calls\nif repl_runtime_is_none() {\n    return Err(anyhow!(\":load baml sources before calling functions\"));\n}","typeGuard":null,"tryCatchPattern":"match result { Err(e) if e.to_string().contains(\"No runtime loaded\") => eprintln!(\"Run :load <baml_src> first\"), other => { let _ = other; } }","preventionTips":["Always run :load before any function-call expression","Confirm load success output before proceeding","Restart the REPL after :reset if function calls still fail"],"tags":["repl","baml","internal-state"],"backgroundTag":"internal-invariant-violation","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"}