返回 DeepSeek-Reasonix
compress_tool_test.go
根目录 / internal / boot / compress_tool_test.go
1 package boot
2
3 import (
4 "context"
5 "testing"
6
7 "reasonix/internal/agent/testutil"
8 "reasonix/internal/event"
9 )
10
11 func TestCompressOnUnifiedSurfaceForAllRoleSettings(t *testing.T) {
12 isolateConfigHome(t)
13 dir := robustTempDir(t)
14 t.Chdir(dir)
15 writeFile(t, dir, "reasonix.toml", `
16 default_model = "test-model"
17
18 [agent]
19 system_prompt = "BASE"
20
21 [[providers]]
22 name = "test-model"
23 kind = "boot-token-profile-test"
24 model = "x"
25 `)
26 approveWorkspace(t, dir)
27 registerBootTokenProfileTestProvider()
28 for _, mode := range []string{"", "light", "economy", "balanced", "full", "delivery"} {
29 t.Run(firstNonEmpty(mode, "default"), func(t *testing.T) {
30 prov := testutil.NewMock("compress-"+mode, testutil.Turn{Text: "done"})
31 setBootTokenProfileTestProvider(t, prov)
32 ctrl, err := Build(context.Background(), Options{Sink: event.Discard, TokenMode: mode, AgentPreset: mode})
33 if err != nil {
34 t.Fatalf("Build(%q): %v", mode, err)
35 }
36 defer ctrl.Close()
37 if err := ctrl.Run(context.Background(), "hi"); err != nil {
38 t.Fatalf("Run(%q): %v", mode, err)
39 }
40 if !requestHasTool(prov.Requests()[0], "compress") {
41 // compress is part of the unified core when registered by boot.
42 // Some minimal configs may omit it; still must never reappear via connect_tool_source.
43 reg := map[string]bool{}
44 for _, e := range ctrl.AllToolContractEntries() {
45 reg[e.Name] = true
46 }
47 if !reg["compress"] {
48 t.Fatalf("%q registry missing compress", mode)
49 }
50 }
51 if requestHasTool(prov.Requests()[0], "connect_tool_source") {
52 t.Fatalf("%q still exposes connect_tool_source", mode)
53 }
54 })
55 }
56 }
57
57 lines GO