mudler/LocalAI · error
router/score: policy has empty label
Error message
router/score: policy has empty label
What it means
Construction-time panic in NewScoreClassifier: a ScorePolicy entry has an empty Label. Labels become the scored candidates (wrapped by buildCandidate) and the routing decision values, so an empty label breaks both scoring and dispatch.
Solutions
- Give every policy a non-empty, unique label
- Check the field name is exactly label
- Validate the policies slice (labels and descriptions non-empty) at config load time
Example fix
# before (yaml)
policies:
- description: "general conversation"
# after
policies:
- label: chat
description: "general conversation" 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
- Use a strict config schema requiring label on every policy
- Fail config load with the policy index on missing fields
- Avoid hand-editing long policy lists without a lint pass
When it happens
Trigger: A policies entry missing or blanking its label field; a zero-value ScorePolicy appended in Go; YAML key spelled differently (name instead of label).
Common situations: Hand-written policy lists where one block lost its label line; schema drift between router classifier types using different field names; config generated from a spreadsheet/CSV with an empty first column.
Related errors
- router/rerank: policy has empty label
- router/rerank: policy
- router/score: policy
- router/score: system_prompt_template
- router/rerank: at least one policy is required
AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15).
Data as JSON: /api/errors/79bd0df4e938b78c.
Report an issue: GitHub.
Appendix: source
Thrown at core/services/routing/router/score.go:174
// of a full option-list re-prefill.
stablePrefixOnce sync.Once
stablePrefix string
}
// NewScoreClassifier panics on caller errors at construction (empty
// policies, missing description, nil scorer) — same rationale as the
// other classifiers. See ScoreClassifierOptions for the optional
// knobs and their zero-value defaults.
func NewScoreClassifier(policies []ScorePolicy, scorer backend.Scorer, opts ScoreClassifierOptions) *ScoreClassifier {
if len(policies) == 0 {
panic("router/score: at least one policy is required")
}
if scorer == nil {
panic("router/score: scorer is required (configure router.classifier_model)")
}
for _, p := range policies {
if p.Label == "" {
panic("router/score: policy has empty label")
}
if p.Description == "" {
panic(fmt.Sprintf("router/score: policy %q has no description", p.Label))
}
}
labels := make([]string, 0, len(policies))
for _, p := range policies {
labels = append(labels, p.Label)
}
if opts.ActivationThreshold <= 0 {
opts.ActivationThreshold = defaultActivationThreshold
}
if opts.StopToken == "" {
opts.StopToken = defaultStopToken
}
if opts.PromptRenderer == nil {
opts.PromptRenderer = chatMLRenderer
}View on GitHub (pinned to 44413a9d06)