File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,26 @@ func TestCompactHistory_EmptyHistory(t *testing.T) {
7474 }
7575}
7676
77+ func TestCompactHistory_MaxHistoryOne (t * testing.T ) {
78+ // maxHistory=1, keep=1/2=0, guard sets keep=1.
79+ // 5 messages → summary + 1 kept = 2.
80+ a := & Agent {maxHistory : 1 }
81+ for i := range 5 {
82+ a .history = append (a .history , provider .NewTextMessage (
83+ provider .RoleUser , fmt .Sprintf ("msg %d" , i )))
84+ }
85+ a .compactHistory ()
86+
87+ if len (a .history ) != 2 {
88+ t .Fatalf ("history len = %d, want 2 (summary + 1 kept)" , len (a .history ))
89+ }
90+
91+ last := a .history [1 ].Content [0 ].Text
92+ if last != "msg 4" {
93+ t .Errorf ("last message = %q, want 'msg 4'" , last )
94+ }
95+ }
96+
7797func TestCompactHistory_ExactThreshold (t * testing.T ) {
7898 a := & Agent {maxHistory : 40 }
7999 for i := range 40 {
You can’t perform that action at this time.
0 commit comments