Fosowl/agenticSeek · critical · Exception
Failed to load the routing model. Please run the dl_safetens
Error message
Failed to load the routing model. Please run the dl_safetensors.sh script inside llm_router/ directory to download the model.
What it means
load_llm_router loads the AdaptiveClassifier safetensors model from ./llm_router (relative to CWD). If loading fails for any reason it raises a single Exception instructing the developer to run dl_safetensors.sh inside llm_router/ to download the model weights. The original exception is swallowed, so the message always points at the most common cause: missing weights.
Source
Thrown at sources/router.py:58
animate_thinking("Loading zero-shot pipeline...", color="status")
return {
"bart": pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
}
def load_llm_router(self) -> AdaptiveClassifier:
"""
Load the LLM router model.
returns:
AdaptiveClassifier: The loaded model
exceptions:
Exception: If the safetensors fails to load
"""
path = "../llm_router" if __name__ == "__main__" else "./llm_router"
try:
animate_thinking("Loading LLM router model...", color="status")
talk_classifier = AdaptiveClassifier.from_pretrained(path)
except Exception as e:
raise Exception("Failed to load the routing model. Please run the dl_safetensors.sh script inside llm_router/ directory to download the model.")
return talk_classifier
def get_device(self) -> str:
if torch.backends.mps.is_available():
return "mps"
elif torch.cuda.is_available():
return "cuda:0"
else:
return "cpu"
def learn_few_shots_complexity(self) -> None:
"""
Few shot learning for complexity estimation.
Use the build in add_examples method of the Adaptive_classifier.
"""
few_shots = [
("hi", "LOW"),
("How it's going ?", "LOW"),View on GitHub (pinned to ae57a23577)
Solutions
- Run `bash dl_safetensors.sh` inside the llm_router/ directory to download the model
- Launch the app from the repository root so ./llm_router resolves correctly (or fix the relative path in router.py:53 to be __file__-based)
- Verify llm_router/ contains config.json and the .safetensors files; re-download if corrupt
- Check disk space and HuggingFace connectivity if the download script itself fails
Example fix
// before path = "../llm_router" if __name__ == "__main__" else "./llm_router" // after import os base = os.path.dirname(os.path.abspath(__file__)) path = os.path.join(os.path.dirname(base), "llm_router") if __name__ == "__main__" else os.path.join(base, "llm_router")
Defensive patterns
Strategy: validation
Validate before calling
import os
path = './llm_router'
weights = [f for f in (os.listdir(path) if os.path.isdir(path) else []) if f.endswith('.safetensors')]
if not weights:
raise SystemExit('Model weights missing. Run: bash llm_router/dl_safetensors.sh') Try / catch
try:
router = Router()
except Exception as e:
if 'dl_safetensors.sh' in str(e):
import subprocess
subprocess.run(['bash', 'llm_router/dl_safetensors.sh'], check=True)
router = Router()
else:
raise Prevention
- Run dl_safetensors.sh as part of repo setup/CI bootstrap
- Always launch the app from the repository root (paths are CWD-relative)
- Verify downloaded weights (config.json + safetensors present, non-zero size) after setup
- Consider making the path in router.py absolute via __file__ to avoid CWD issues
When it happens
Trigger: Instantiating the router (Router.__init__ -> load_llm_router) when AdaptiveClassifier.from_pretrained('./llm_router') fails — directory absent, weights never downloaded, partial/corrupt download, or CWD is not the repo root so the relative path resolves wrong.
Common situations: Fresh clone without running dl_safetensors.sh; launching the app from a different working directory (the path is CWD-relative, not file-relative); interrupted download leaving corrupt safetensors; missing config.json alongside weights.
Related errors
AI-assisted analysis of Fosowl/agenticSeek@ae57a23577 (2026-08-30).
Data as JSON: /api/errors/ad13c7ebccd375ca.
Report an issue: GitHub.