mudler/LocalAI · error

router/rerank: policy %q has no description

Error message

router/rerank: policy %q has no description

What it means

Construction-time panic in NewRerankClassifier: a policy has a label but an empty Description. Descriptions are the documents the reranker scores the incoming prompt against — with no description the classifier could never activate that policy, so construction refuses.

Source

Thrown at core/services/routing/router/rerank.go:51

// 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,
		documents:           docs,
		cache:               newLabelSetCache(cacheCap),
	}

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Write a meaningful description for each policy describing the requests it should match
  2. Audit every policy entry for both label and description keys
  3. Treat descriptions as prompts: make them specific enough for the reranker to discriminate

Example fix

# before (yaml)
policies:
  - label: code
# after
policies:
  - label: code
    description: "requests about writing, debugging, or explaining code"
Defensive patterns

Strategy: validation

Validate before calling

for i, p := range policies {
    if strings.TrimSpace(p.Description) == "" {
        return fmt.Errorf("policy %q: empty description", p.Label)
    }
}

Type guard

func validDescriptions(ps []ScorePolicy) bool { for _, p := range ps { if p.Description == "" { return false } }; return true }

Prevention

When it happens

Trigger: A policies entry with only a label (description key missing or empty string); YAML value quoted as empty (description: ""); a zero-value description after templating/config interpolation.

Common situations: Minimal config written from an example that truncated the description line; templating variable for description resolving to empty; misunderstanding description as optional metadata rather than required scoring input.

Related errors


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/5cff96a308ec47ed. Report an issue: GitHub.