mudler/LocalAI · error

router/score: policy %q has no description

Error message

router/score: policy %q has no description

What it means

Construction-time panic in NewScoreClassifier: a policy has a label but an empty Description. Descriptions feed the system prompt rendered by renderSystemPrompt and give the scorer context to discriminate labels; an empty one makes the policy unusable, so construction aborts with the offending label quoted.

Source

Thrown at core/services/routing/router/score.go:177

}

// 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
	}
	switch opts.Normalization {
	case "", ScoreNormalizationRaw:
		opts.Normalization = ScoreNormalizationRaw

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Write a discriminative description for each policy
  2. Audit all entries for both label and description
  3. Add a pre-flight config lint that reports the specific policy missing a description

Example fix

# before (yaml)
policies:
  - label: chat
# after
policies:
  - label: chat
    description: "general conversation and Q&A"
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 label only; description key present but empty/templating resolves to ''; programmatic ScorePolicy with Description unset.

Common situations: Truncated example configs; CI config tests that fill labels programmatically but skip descriptions; belief that description is optional documentation rather than scoring input.

Related errors


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