返回 DeepSeek-Reasonix
repeat_reminder_test.go
根目录 / internal / agent / repeat_reminder_test.go
1 package agent
2
3 import (
4 "strings"
5 "testing"
6
7 "reasonix/internal/provider"
8 )
9
10 func TestRepeatReminderAtThreeFiveEightNeverBlocks(t *testing.T) {
11 a := &Agent{}
12 call := provider.ToolCall{Name: "read_file", Arguments: `{"limit":1,"path":"secret.txt"}`}
13 for count := 1; count <= 8; count++ {
14 results := []string{"ok"}
15 a.applyRepeatReminders([]provider.ToolCall{call}, results)
16 want := count == 3 || count == 5 || count == 8
17 if got := strings.Contains(results[0], "[repeat reminder]"); got != want {
18 t.Fatalf("count %d reminder=%v want=%v: %q", count, got, want, results[0])
19 }
20 if strings.Contains(results[0], "secret.txt") {
21 t.Fatal("reminder copied sensitive arguments")
22 }
23 }
24 }
25
26 func TestRepeatReminderCanonicalizesJSONAndResetsOnChange(t *testing.T) {
27 a := &Agent{}
28 for _, args := range []string{`{"path":"a","limit":1}`, `{"limit":1,"path":"a"}`, `{"path":"a", "limit":1}`} {
29 results := []string{"ok"}
30 a.applyRepeatReminders([]provider.ToolCall{{Name: "read_file", Arguments: args}}, results)
31 }
32 if a.turn.repeatCount != 3 {
33 t.Fatalf("count=%d", a.turn.repeatCount)
34 }
35 a.applyRepeatReminders([]provider.ToolCall{{Name: "read_file", Arguments: `{"path":"b"}`}}, []string{"ok"})
36 if a.turn.repeatCount != 1 {
37 t.Fatalf("changed call did not reset: %d", a.turn.repeatCount)
38 }
39 }
40
40 lines GO