Make prompt tests resilient to wording changes
This commit is contained in:
@@ -17,7 +17,7 @@ func TestNativeReconciliationPromptPairPreparesOffline(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
correction := CorrectionRequest(CorrectionPromptID, "test-profile", "session-1", []string{"Use only candidate numbers in the supplied range.", "Preserve distinct entities."})
|
||||
correction := CorrectionRequest(CorrectionPromptID, "test-profile", "session-1", []string{"guidance-one-sentinel", "guidance-two-sentinel"})
|
||||
if len(correction.Inputs) != 1 {
|
||||
t.Fatal("correction regenerated fixed evidence")
|
||||
}
|
||||
@@ -37,23 +37,12 @@ func TestNativeReconciliationPromptPairPreparesOffline(t *testing.T) {
|
||||
}
|
||||
if i == 0 {
|
||||
first = prepared
|
||||
var system string
|
||||
for _, message := range prepared.Messages {
|
||||
if message.Role == "system" {
|
||||
system += message.Content
|
||||
}
|
||||
}
|
||||
for _, rule := range []string{"candidate_number_range", "not candidate numbers", "do not copy candidate names", "Preserve distinct entities"} {
|
||||
if !strings.Contains(system, rule) {
|
||||
t.Fatalf("missing enduring system principle %q", rule)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if !reflect.DeepEqual(first.OutputContract, prepared.OutputContract) || len(prepared.Messages) != 1 || prepared.Messages[0].Role != "user" {
|
||||
t.Fatal("correction changed native contract or supplied more than a follow-up assignment")
|
||||
}
|
||||
text := prepared.Messages[0].Content
|
||||
if !strings.Contains(text, "Use only candidate numbers") || !strings.Contains(text, "complete replacement proposal") {
|
||||
if strings.Count(text, "guidance-one-sentinel") != 1 || strings.Count(text, "guidance-two-sentinel") != 1 {
|
||||
t.Fatal("correction lost findings or assignment")
|
||||
}
|
||||
for _, material := range preparation.Materials() {
|
||||
|
||||
@@ -17,9 +17,9 @@ func TestSpellPromptPairSharesNativeContractAndDefaultProfile(t *testing.T) {
|
||||
inputs := map[string]promptkit.ArtifactRef{"guidance": promptkit.Inline("Fix the rejected cast.")}
|
||||
if id == PromptID {
|
||||
inputs = map[string]promptkit.ArtifactRef{
|
||||
"transcript": promptkit.Inline(`{"units":[1,2]}`),
|
||||
"spell_catalog": promptkit.Inline(`{"spells":[]}`),
|
||||
"npc_registry": promptkit.Inline(`{"npcs":[]}`),
|
||||
"transcript": promptkit.Inline(`{"sentinel":"spell-transcript-sentinel"}`),
|
||||
"spell_catalog": promptkit.Inline(`{"sentinel":"spell-catalog-sentinel"}`),
|
||||
"npc_registry": promptkit.Inline(`{"sentinel":"spell-npcs-sentinel"}`),
|
||||
"players": promptkit.Inline(" "), "party": promptkit.Inline(" "), "glossary": promptkit.Inline(" "),
|
||||
}
|
||||
}
|
||||
@@ -37,19 +37,24 @@ func TestSpellPromptPairSharesNativeContractAndDefaultProfile(t *testing.T) {
|
||||
}
|
||||
if id == PromptID {
|
||||
initial = prepared
|
||||
var system string
|
||||
for _, message := range prepared.Messages {
|
||||
if message.Role == "system" {
|
||||
system += message.Content
|
||||
for _, sentinel := range []string{"spell-transcript-sentinel", "spell-catalog-sentinel", "spell-npcs-sentinel"} {
|
||||
var count int
|
||||
for _, message := range prepared.Messages {
|
||||
count += strings.Count(message.Content, sentinel)
|
||||
}
|
||||
if count != 1 {
|
||||
t.Fatalf("input %q rendered %d times", sentinel, count)
|
||||
}
|
||||
}
|
||||
if !strings.Contains(system, "canonical spelling exactly") || !strings.Contains(system, "in-world caster") {
|
||||
t.Fatal("enduring spell constraints missing from initial system context")
|
||||
}
|
||||
} else {
|
||||
if !reflect.DeepEqual(initial.OutputContract, prepared.OutputContract) || len(prepared.Messages) != 1 || prepared.Messages[0].Role != "user" || !strings.Contains(prepared.Messages[0].Content, "Fix the rejected cast.") {
|
||||
t.Fatal("correction must supply only findings and a replacement assignment with the same contract")
|
||||
}
|
||||
for _, sentinel := range []string{"spell-transcript-sentinel", "spell-catalog-sentinel", "spell-npcs-sentinel"} {
|
||||
if strings.Contains(prepared.Messages[0].Content, sentinel) {
|
||||
t.Fatalf("correction repeated input %q", sentinel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(client.requests) != 0 {
|
||||
|
||||
Reference in New Issue
Block a user