fix: simplify persona resolution to single path, use personaDesc for system prompt

This commit is contained in:
2026-06-17 01:09:36 +02:00
parent 03a321e542
commit 60e3eff9d2
+12 -22
View File
@@ -197,34 +197,24 @@ func (p *Plugin) MessageHasBeenPosted(c *plugin.Context, post *model.Post) {
// Prepend the persona system prompt to set the bot's character.
// Priority: KV override > dropdown selection
// KV "custom" or dropdown "custom" → use CustomPersona textarea field
// Otherwise → resolve from personaLibrary
// "custom" → CustomPersona textarea (falls back to defaultCustomPersona if empty)
// otherwise → resolve from personaLibrary
persona := p.GetPersonaOverride(post.UserId, post.ChannelId)
if persona == "" {
persona = cfg.Persona
}
var personaDesc string
if persona == "custom" {
persona = cfg.CustomPersona
if persona == "" {
persona = defaultCustomPersona
personaDesc = cfg.CustomPersona
if personaDesc == "" {
personaDesc = defaultCustomPersona
}
} else {
persona = resolvePersona(persona)
}
if persona == "" {
if cfg.Persona == "custom" {
persona = cfg.CustomPersona
if persona == "" {
persona = defaultCustomPersona
}
} else {
persona = resolvePersona(cfg.Persona)
// If resolvePersona returned empty but a value was set, use it as-is (legacy fallback).
if persona == "" && cfg.Persona != "" {
persona = cfg.Persona
}
}
personaDesc = resolvePersona(persona)
}
systemPrompt := ""
if persona != "" {
systemPrompt = "You are " + persona + ". Respond in character. Only respond to the latest message — do not re-address earlier messages. Vary your openings and phrasing each time."
if personaDesc != "" {
systemPrompt = "You are " + personaDesc + ". Respond in character. Only respond to the latest message — do not re-address earlier messages. Vary your openings and phrasing each time."
if cfg.Brevity != "" && cfg.Brevity != "0" {
systemPrompt += " Reply in " + cfg.Brevity + " sentences or fewer."
}