package runtime import ( "strings" "testing" core "git-ssh.u1680832.nyat.app/weichen/Agent-System-Core.git" ) // 窗口按 token 配置并换算为字符阈值;此前 32000 字符硬默认会让长材料任务 // 在第一个请求就触发清理(被清内容只留「见会话记录」,模型无法取回)。 func TestContextWindowScalesFromTokens(t *testing.T) { eff := core.EffectiveSettings{"models": map[string]any{"chat": map[string]any{ "contextWindow": float64(128000), "outputReserve": float64(16384), "contextBuffer": float64(4096), }}} w, r, b := contextWindow(eff) if w != int(128000*3.35) { t.Fatalf("window = %d, want %d", w, int(128000*3.35)) } if r <= 0 || b <= 0 { t.Fatalf("reserve/buffer must be positive chars: %d %d", r, b) } // 旧部署未配置时的默认:不再是 32k 字符。 def, _, _ := contextWindow(core.EffectiveSettings{}) if def < 100000*3 { t.Fatalf("default window too small: %d", def) } } func TestThinkReplayEnabled(t *testing.T) { eff := func(v string) core.EffectiveSettings { return core.EffectiveSettings{"context": map[string]any{"thinkReplay": v}} } if !thinkReplayEnabled(eff(""), "MiniMax-M2.7-highspeed") { t.Fatal("auto should enable for minimax models") } if thinkReplayEnabled(eff(""), "gpt-5.1") { t.Fatal("auto should stay off for other models") } if !thinkReplayEnabled(eff("on"), "gpt-5.1") { t.Fatal("explicit on must win") } if thinkReplayEnabled(eff("off"), "MiniMax-M2.7-highspeed") { t.Fatal("explicit off must win") } if !strings.Contains("checkpoint", "checkpoint") { t.Fatal("sanity") } }