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