@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: 4f94b8a82 wrote 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/main 64ae6e206):
- Red on the old code: with settings.go and model_cli.go from 64ae6e206,
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 at 64ae6e206
alone ("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).