Give every prompt one shared context block
The "address him as ты" rule had only reached two of the five system prompts. Instead of pasting it into the other three (five copies drift — that is how this happened), there is now one block, in internal/persona, prepended to all five: nudges, action replies, chat, note queries and general knowledge. The block says who he is and how to address him (a man, always "ты", never "вы", never "он" about him; Maven stays feminine), plus the current local date and time. It is rendered fresh each turn because the time changes, and it is correct with an empty config — the address and gender rules are defaults in code. Config only adds optional facts: owner_name, city, and the existing free-text `persona` string, which is now the static half of the block. Russian even in front of the English prompts: the rules are Russian grammar, so they read best stated in Russian, and there is one copy. Vikunja #394. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CGeSZxh1DCtRxmFVSYVGvJ
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package phraser
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Every phrasing prompt must carry the shared context block. This is the
|
||||
// regression guard for the bug that started this: the "ты" rule reached only
|
||||
// two of the five prompts because each prompt had its own copy of the rules.
|
||||
func TestEveryPromptCarriesTheContextBlock(t *testing.T) {
|
||||
block := func() string { return "CTXBLOCK" }
|
||||
p := &LLMPhraser{cfg: Config{ContextBlock: block}}
|
||||
|
||||
prompts := map[string]string{
|
||||
"nudge": p.systemPrompt(),
|
||||
"query": p.querySystemPrompt(),
|
||||
"chat": chatSystemPrompt(block),
|
||||
}
|
||||
for name, got := range prompts {
|
||||
if !strings.HasPrefix(got, "CTXBLOCK\n\n") {
|
||||
t.Errorf("%s prompt does not start with the context block:\n%s", name, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Without a block the prompts are unchanged — the stub and test paths pass nil.
|
||||
func TestPromptsWithoutBlockAreUnchanged(t *testing.T) {
|
||||
p := &LLMPhraser{}
|
||||
if p.systemPrompt() != nudgeSystem {
|
||||
t.Errorf("nudge prompt changed with no block set")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user