@taktoshilite: the Grok config magpie writes says auto_compact_threshold_percent = 25-something and 50-something, so a 1M model compacts at a quarter of its window; they asked for ~90%. Cause:4f94b8a82wrote each model's whole window as context_window plus a percent from Long conversations. Its default is settings.WorkingWindow, 272K (Codex's own window), so a 1M model got 27% and a 524288 one 51%. Grok Build's own default is 85 (resolve/compaction.rs, DEFAULT_AUTO_COMPACT_THRESHOLD_PERCENT), 80 for xAI's own models in default_models.json. Change: settings.ForAgent("grok") reads magpie's default (no global size, no Grok entry) as Full window, so no percent is written and Grok Build uses its own 85% (1M compacts near 850K). A size the user picks still goes in: a global or Grok-only size writes its percent (900K on a 1M model = 90), and Grok's own {} entry keeps 272K. A percent typed by hand in ~/.grok/config.toml is kept as before (grokOwnPercent). The stale 27/51 magpie wrote is dropped on the next sync, since the stash marks it as magpie's. CLI (`magpie model compact`) and the Grok Build sheet say Grok compacts at its own threshold; sub text translated into zh, zh-TW, ja, de. docs/subsystems/agent-wiring.md says so. Tests: - TestGrokCompactsAtItsOwnPercentByDefault (internal/agent): catalog windows 1M and 524288, an old config with magpie's 27/51; default writes none, Grok {} gives 27/51, 900K gives 90, a hand-set 90 stays. - TestGrokFollowsItsOwnThresholdByDefault (internal/settings). - grok-compact.test.cjs: Grok sheet shows Full pressed, posts own at on a click, 900K shows 900k; Claude's row unchanged; en/zh/zh-TW/ja/de, Chromium + WebKit, 900px and 420px. Run (mote, at e702accf9's tree on origin/main64ae6e206): - Red on the old code: with settings.go and model_cli.go from64ae6e206, the agent test fails "magpie's default: big 27%, mid 51%" (the reporter's numbers) and the settings test fails at "default". - go test -count=1 -tags nogui ./internal/settings ./internal/agent ./internal/cli ./internal/provider: all ok (agent 288s, provider 170s) - go vet (those packages), GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: clean - gofmt -l: clean. - GUI: grok-compact, agent-compact, i18n-keys, agent-prefs, compact-at pass; agent-details-ready 32 of 36 red, the same 32 at64ae6e206alone ("ends ~80px short and jumps", #6373). Not tried: a real Grok Build conversation compacting at 85% on a 1M model; the full Go suite (mote and mica were over their cores).
33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
package settings
|
|
|
|
import "testing"
|
|
|
|
// Grok Build reads magpie's default for every agent as its whole window,
|
|
// where it compacts at its own percent (@taktoshilite on X), while a size
|
|
// typed for every agent or for Grok Build, and Codex's and Claude Code's
|
|
// default, are as they were.
|
|
func TestGrokFollowsItsOwnThresholdByDefault(t *testing.T) {
|
|
var s Settings
|
|
if g := s.ForAgent("grok"); !g.FullContext || g.Compact() != 0 || !s.GrokOwnCompact() {
|
|
t.Fatalf("default: grok full %v, at %d", g.FullContext, g.Compact())
|
|
}
|
|
for _, k := range []string{"codex", "claude"} {
|
|
if n := s.ForAgent(k).Compact(); n != WorkingWindow {
|
|
t.Fatalf("%s's default %d", k, n)
|
|
}
|
|
}
|
|
s.CompactAt = 400000
|
|
if n := s.ForAgent("grok").Compact(); n != 400000 || s.GrokOwnCompact() {
|
|
t.Fatalf("400K for every agent: grok %d", n)
|
|
}
|
|
s.CompactAt = 0
|
|
s.AgentCompacts = map[string]AgentCompact{"grok": {}}
|
|
if n := s.ForAgent("grok").Compact(); n != WorkingWindow || s.GrokOwnCompact() {
|
|
t.Fatalf("272K picked for grok: %d", n)
|
|
}
|
|
s.AgentCompacts = map[string]AgentCompact{"codex": {At: 300000}}
|
|
if g := s.ForAgent("grok"); !g.FullContext {
|
|
t.Fatalf("codex's own reached grok: %+v", g.Compact())
|
|
}
|
|
}
|