BoundaryML/baml · error
No runtime loaded, it should be impossible to call an LLM fu
Error message
No runtime loaded, it should be impossible to call an LLM function
What it means
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.
Source
Thrown at engine/baml-runtime/src/cli/repl.rs:602
output_tokens: resp.metadata.output_tokens,
total_tokens: resp.metadata.total_tokens,
cached_input_tokens: resp.metadata.cached_input_tokens,
};
let _ = tx.send(LlmStatusEvent::Finished(run_id, Some(usage)));
} else {
let _ = tx.send(LlmStatusEvent::Finished(run_id, None));
}
}
match function_result.parsed() {
Some(Ok(response_baml_value)) => Ok(response_baml_value
.clone()
.0
.map_meta_owned(|_| (Span::fake(), None))),
Some(Err(e)) => Err(anyhow!("Failed to parse function result: {}", e)),
None => Err(anyhow!("No parsed result available from function call")),
}
}
None => Err(anyhow!(
"No runtime loaded, it should be impossible to call an LLM function"
)),
}
}
};
// REPL watch handler: collect notifications
let watch_notifications = Arc::new(Mutex::new(Vec::new()));
let watch_notifications_clone = watch_notifications.clone();
let watch_handler = shared_handler(move |notification| {
watch_notifications_clone
.lock()
.unwrap()
.push(format!("{notification}"));
});
let eval_result = interpret_thir(
"repl".to_string(),
thir.clone(),View on GitHub (pinned to bd85ce9dee)
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
Example fix
// before (REPL input) MyFn(1) // no sources loaded // after :load ./baml_src MyFn(1)
Defensive patterns
Strategy: validation
Validate before calling
// Guard in embedding code before evaluating function calls
if repl_runtime_is_none() {
return Err(anyhow!(":load baml sources before calling functions"));
} Try / catch
match result { Err(e) if e.to_string().contains("No runtime loaded") => eprintln!("Run :load <baml_src> first"), other => { let _ = other; } } Prevention
- Always run :load before any function-call expression
- Confirm load success output before proceeding
- Restart the REPL after :reset if function calls still fail
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- No BAML sources loaded. Use :load <path> to load sources.
- Type error: {}
- LLM Function {} not found
- Failed to parse function result: {}
- No parsed result available from function call
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/6280426023a19959.
Report an issue: GitHub.