mudler/LocalAI · error
router/rerank: policy has empty label
Error message
router/rerank: policy has empty label
What it means
Construction-time panic in NewRerankClassifier: one of the supplied ScorePolicy entries has an empty Label. Labels are both the routing output value and the reranker candidate text anchor, so an empty label is meaningless downstream and is rejected eagerly.
Source
Thrown at core/services/routing/router/rerank.go:48
budget *lazyBudget
}
// defaultRerankActivationThreshold is the relevance floor a label
// must clear to be considered active. Reranker scores live in [0, 1]
// for cross-encoder / ColBERT heads; 0.5 picks "more positive than
// not on this label."
const defaultRerankActivationThreshold = 0.5
func NewRerankClassifier(policies []ScorePolicy, reranker backend.Reranker, cacheCap int, activationThreshold float64) *RerankClassifier {
if len(policies) == 0 {
panic("router/rerank: at least one policy is required")
}
if reranker == nil {
panic("router/rerank: reranker is required (configure router.classifier_model)")
}
for _, p := range policies {
if p.Label == "" {
panic("router/rerank: policy has empty label")
}
if p.Description == "" {
panic(fmt.Sprintf("router/rerank: policy %q has no description", p.Label))
}
}
if activationThreshold <= 0 {
activationThreshold = defaultRerankActivationThreshold
}
labels := make([]string, len(policies))
docs := make([]string, len(policies))
for i, p := range policies {
labels[i] = p.Label
docs[i] = p.Description
}
return &RerankClassifier{
reranker: reranker,
activationThreshold: activationThreshold,
labels: labels,View on GitHub (pinned to 44413a9d06)
Solutions
- Find the policy without a label in the router config and give it a non-empty label
- Check for singular/plural or misnamed keys (label, not labels/name)
- Add config-time validation to report which policy index is malformed before the panic
Example fix
# before (yaml)
policies:
- description: "programming questions"
# after
policies:
- label: code
description: "programming questions" Defensive patterns
Strategy: validation
Validate before calling
for i, p := range policies {
if strings.TrimSpace(p.Label) == "" {
return fmt.Errorf("policy %d: empty label", i)
}
} Type guard
func validLabels(ps []ScorePolicy) bool { for _, p := range ps { if p.Label == "" { return false } }; return true } Prevention
- Lint router policies for label+description presence
- Use strict YAML schemas that reject missing keys
- Generate policy lists from tested templates
When it happens
Trigger: A policies list entry missing its label key, or label: "" in YAML; programmatically appending a zero-value ScorePolicy{}; whitespace-only labels after trimming in config.
Common situations: YAML typo (labels vs label, or the field named differently); copy-pasted policy block with the label line accidentally removed; config schema that allows label to be optional.
Related errors
- router/rerank: policy %q has no description
- router/score: policy has empty label
- router/score: policy %q has no description
- router/score: system_prompt_template: %v
- router/rerank: at least one policy is required
AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15).
Data as JSON: /api/errors/f2045b8b26fda46b.
Report an issue: GitHub.