返回 DeepSeek-Reasonix
compact_chunked_policy_test.go
根目录 / internal / agent / compact_chunked_policy_test.go
1 package agent
2
3 import (
4 "context"
5 "errors"
6 "testing"
7
8 "reasonix/internal/event"
9 "reasonix/internal/tool"
10 )
11
12 func TestPressureCompactionDoesNotCallChunkedFold(t *testing.T) {
13 prov := &extractStubProvider{failFirst: 64, reply: "digest"}
14 a := agentOverForce(t, prov, foldableSessionOverForce(12))
15 if err := prepareContext(context.Background(), a, CompactionTriggerPressure); !errors.Is(err, ErrCompactionRequired) {
16 t.Fatalf("prepare = %v, want a recoverable context failure", err)
17 }
18 if degradedFold(a) {
19 t.Fatal("pressure compaction must not install a fabricated summary")
20 }
21 assertNoFailedSummaryRewrite(t, a)
22 if prov.calls > 2 {
23 t.Fatalf("provider calls = %d, want at most one summary plus one retry, not chunked/tree-reduce", prov.calls)
24 }
25 }
26
27 func TestExplicitChunkedFallbackStillRuns(t *testing.T) {
28 prov := &extractStubProvider{failFirst: 1, reply: "digest"}
29 a := New(prov, tool.NewRegistry(), extractStubSession(), Options{}, event.Discard)
30 fold := a.Session().Snapshot()
31 if _, _, err := a.foldSummaryWithChunkedFallback(context.Background(), CompactionTriggerManual, fold, "focus", 321, SummaryInputCachePrefix); err != nil {
32 t.Fatalf("explicit chunked fallback: %v", err)
33 }
34 if prov.calls < 2 {
35 t.Fatalf("provider calls = %d, want the failed summary plus chunked recovery", prov.calls)
36 }
37 }
38
38 lines GO