magpie wrote Long conversations' compaction threshold into each
[model."magpie/..."] table's context_window. Grok Build reads
context_window as the model's whole window and compacts at a percent of
it: auto_compact_threshold_percent in [model.<id>], else [session]'s,
else 85 (xai-org/grok-build 559751fd:
xai-grok-shell/src/util/config/resolve/compaction.rs,
DEFAULT_AUTO_COMPACT_THRESHOLD_PERCENT and
resolve_auto_compact_threshold_percent; GROK_AUTO_COMPACT_THRESHOLD_PERCENT
above all). So a 1M model held to 300K compacted at 255K and never had
its real window.
Now context_window is the catalog's whole window, and where magpie has
it compact (grokCompactAt, the old grokWindow rule: the model's or
provider's threshold, else settings.Working, none under Full window)
goes in as auto_compact_threshold_percent of the window written,
rounded down, at least 1 (grokPercent). None leaves Grok's own 85.
- A table an older magpie wrote with the threshold as its window, on
record in grok:<path>:windows, gets the whole window back.
- A percent the user set in one of magpie's tables stays: what magpie
gave is stashed in grok:<path>:percents, and one it has no record of
giving is the user's (grokOwnPercent). A context_window set by hand
still stays (grokOwnWindow).
- A [session] auto_compact_threshold_percent is the user's for every
model, so magpie writes no per-model one over it.
Siblings: Codex (codexcat) already writes context_window and
auto_compact_token_limit apart, and Claude Code has
CLAUDE_CODE_MAX_CONTEXT_TOKENS beside CLAUDE_CODE_AUTO_COMPACT_WINDOW.
Grok App (grokapp.go) writes the model's own window. Only Grok Build
had the threshold in its window key.
Run:
- At cfca72eaf (this change on f9492fd8e), on mica (mote was over its
cores): gofmt -l clean; go vet ./internal/agent ./internal/settings,
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok;
go test -count=1 -timeout 45m ./... ok, go-exit=0.
- At this head, rebased on f1a4de736 (internal/agent changed in
6abea5f8e): gofmt, vet and go test ./internal/agent
./internal/settings ./internal/gui on mica: gofmt clean, vet ok, all three ok (agent 195s, settings 16s, gui 137s).
- Broken by hand: the new tests run against origin/main's grok.go (with
a shim for grokHadIn) are red: TestGrokWindowIsTheModelsAndCompactsAtThePercent
(pro 300000, want 1M), TestGrokKeepsTheUsersCompactPercent,
TestGrokWindowFollowsLongConversations, TestGrokKeepsAWindowSetBeforeTheRecord.
- Real grok 1.0.67 in a sandbox HOME/GROK_HOME: `grok models` and
`grok inspect` take a table with context_window = 1000000 and
auto_compact_threshold_percent = 30 with no config warning (a
misspelt key is reported as "unknown field", so the check sees it).
Not tried: a real Grok conversation running up to the threshold to
watch it compact at 300K.