Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

grok: each model's context_window follows Long conversations, and one set by hand stays through a sync (uk.jent)

yetonea0ba8e1f2efc
diff --git a/docs/subsystems/agent-wiring.md b/docs/subsystems/agent-wiring.md
index 75b08c8c2..ce6da5d31 100644
--- a/docs/subsystems/agent-wiring.md
+++ b/docs/subsystems/agent-wiring.md
@@ -76,7 +76,7 @@ something else shows up as drift.
- OpenPencil (ZSeven-W/openpencil, the `openpencil-desktop` app) keeps the builtin agents its chat runs on in `settings.json` in Rust's `dirs::config_dir()` joined with `openpencil`: `~/Library/Application Support/openpencil` on a Mac, `$XDG_CONFIG_HOME` or `~/.config` on Linux, `%APPDATA%` on Windows (`openPencil` in [`openpencil.go`](../../internal/agent/openpencil.go); its `settings_io.rs` and `settings_payload.rs`). magpie adds one entry to `builtin_agents`, `id: magpie`, `kind: openai-compat` at the gateway's `/v1` with a key naming OpenPencil (its User-Agent isn't known), `preset: custom`, the picked models as OpenPencil writes a list: the first as `model`, `models` only for two or more, at most 64 (v0.8.4 reads `model` alone). The user's other entries and settings stay, and so do the `display_name` and `enabled` they give magpie's entry; a sync with nothing to change doesn't write. OpenPencil needs `"version": 1` (a file without it is set aside as corrupt and saving stops), so magpie writes it in a file it makes and leaves a file with any other version, or none, alone. Disconnect takes the entry out, and the file when only the version and an empty list are left. OpenPencil reads the file once at start and writes it back whole when it quits, so a change is refused while `openpencil-desktop` runs (Windows can't be asked, so the notice says to quit it first). The model is picked in OpenPencil's chat, so the field is whether magpie is in its picker (`ListsModels`). Detected by its settings folder, `~/.openpencil` (its CLI's), `OpenPencil.app` (`com.zseven-w.openpencil`), or `%ProgramFiles%\OpenPencil`. open-pencil/open-pencil, the other app of the name, keeps its providers in its webview's localStorage, so it is not a row: it reaches magpie through Pi or an ACP agent magpie wires.
- NewMax (newmax.cc, an Electron app on the Claude Agent SDK) keeps its settings as JSON in the row `app` of the `settings` table of `newmax.db`, a SQLite database in WAL mode in `$NEWMAX_USER_DATA_DIR`, else `~/.newmax` on every system (`newMax` in [`newmax.go`](../../internal/agent/newmax.go); its main bundle's `configureAppDataPaths`, `loadPersistedAppSettings` and the renderer's `mergeProviders`, v1.1.22). magpie adds one entry to `providers` in the shape NewMax's own import writes, `id: magpie-gateway` (its own preset is `magpie`, its import's ids hold `%3A`), `apiFormat: anthropic` at the gateway's root (NewMax appends `/v1/messages`) with `ANTHROPIC_AUTH_TOKEN` and a key naming NewMax, at most 20 models (`MAX_MODELS`) as `models` and `enabledModels` with their context windows, and its id at the end of `providerOrder`. The row is edited in place in one immediate transaction, so every other byte stays; the user's `name` and `enabled` for magpie's entry and the fields NewMax adds to it stay through a sync, and a sync with nothing to change doesn't write. A row that isn't a JSON object, or whose `providers` or `providerOrder` isn't a list, is left alone. With no row (NewMax at its defaults), magpie writes one with its entry alone, as NewMax lays its defaults and presets under the row; with no database yet, it asks to open NewMax once. Disconnect takes the entry and the id out, sets a pick of it back to `default`, and takes the row out when only what magpie made is left. NewMax holds its settings in memory and writes the whole row back whenever one changes, so a change is refused while `NewMax` (`newmax` on Linux) runs (Windows can't be asked, so the notice says to quit it first). The model is picked in NewMax's model picker, so the field is whether magpie is in it (`ListsModels`). Detected by its data folder or `NewMax.app` (`cc.newmax.desktop`).
- DevEco Code (Huawei's OpenCode fork, #1885) is wired as OpenCode is (`deveco` in [`agents.go`](../../internal/agent/agents.go)): magpie's provider goes into the first of `deveco.jsonc`, `deveco.json` and `config.json` in `~/.config/deveco` (the one DevEco merges last, so the one that wins), or in `$DEVECO_CONFIG_DIR` when that is absolute, read after them. 0.2.3 sends `deveco/0.2.3 ai-sdk/…` to a provider of its config, but much of the OpenCode code it keeps still sends OpenCode's own User-Agent (`opencode/<version>`), so its provider's key is `magpie-deveco` (`openCodeKeyAt`), not the plain `magpie` OpenCode and MiMo Code send, and Check asks for that key. Its npm package has no Linux binary, so no install command is offered there (`cliSpec.only`).
-- Grok Build keeps magpie's models as one `[model."magpie/<provider>/<model>"]` table each in `config.toml` under `$GROK_HOME`, else `~/.grok` (`grok` in [`grok.go`](../../internal/agent/grok.go)), each on the gateway's `/v1` with magpie's key. Grok Build takes `api_backend` per model table, `"chat_completions"` (its default), `"responses"` or `"messages"` (Anthropic Messages), and sends each to `base_url` joined with `/chat/completions`, `/responses` or `/messages` (the "Supported API Backends" page bundled in its binary; grok 1.0.67). magpie writes each model's native API (`grokBackend`, from `catalog.Model.APIs` as Pi, droid and dsh pick theirs; uk.jent on Discord), so the gateway relays the request as it is: Responses for a model served best there, Messages for a Claude on an Anthropic endpoint, Chat for the rest, a group whose members differ, or one not known.
+- Grok Build keeps magpie's models as one `[model."magpie/<provider>/<model>"]` table each in `config.toml` under `$GROK_HOME`, else `~/.grok` (`grok` in [`grok.go`](../../internal/agent/grok.go)), each on the gateway's `/v1` with magpie's key. Grok Build takes `api_backend` per model table, `"chat_completions"` (its default), `"responses"` or `"messages"` (Anthropic Messages), and sends each to `base_url` joined with `/chat/completions`, `/responses` or `/messages` (the "Supported API Backends" page bundled in its binary; grok 1.0.67). magpie writes each model's native API (`grokBackend`, from `catalog.Model.APIs` as Pi, droid and dsh pick theirs; uk.jent on Discord), so the gateway relays the request as it is: Responses for a model served best there, Messages for a Claude on an Anthropic endpoint, Chat for the rest, a group whose members differ, or one not known. Each table's `context_window` "drives auto-compact timing" (Grok Build's config reference), so it is where Long conversations has Codex compact (`grokWindow`, codexcat's rule): a threshold set on the model or its provider, else `settings.Working` of the model's window, the whole window under Full window; Long conversations is in Grok Build's sheet on the Agents page (`AGENT_PREFS`). A `context_window` the user set in one of magpie's tables by hand stays through a sync and a new pick (uk.jent on Discord: dozens of 1M models set to 300K one by one): what magpie last gave each model is stashed (`grok:<path>:windows`), and a value other than it is the user's (`grokOwnWindow`). With no record yet (a config an older magpie wrote, which gave every model its whole window), a value other than the model's whole window and other than magpie's now is taken for the user's. Disconnect drops the record with the tables. `TestGrokKeepsAWindowSetByHand`, `TestGrokKeepsAWindowSetBeforeTheRecord`, `TestGrokWindowFollowsLongConversations`.
- Grok App (RongleCat/grok-app, a desktop front end that starts Grok Build over ACP) keeps its provider channels in `agent-home/config.toml` under its data folder: `$GROK_APP_HOME`, else where its `directories` crate puts it, or its `~/.grok-app` fallback when that is the one there (`grokApp` in [`grokapp.go`](../../internal/agent/grokapp.go)). Its composer lists only Grok Build's official catalog, never the `[model."magpie/…"]` tables of Grok Build's row, so magpie adds itself as a channel, `[model.magpie]`, with the keys the App's Providers page writes: the gateway's `/v1`, a key naming Grok App, `api_backend = "chat_completions"`, `app_provider_mode = "generic"`, and `app_models`, a JSON list of magpie's models with `contextWindow`, `supportsVision` and their effort levels (no `none`; a default the user marks in the App stays, else medium). The picked model's `context_window` (a bare integer) and `supports_reasoning_effort` (a bare bool, Grok Build's gate for `--reasoning-effort`) are on the channel, as the App puts them there when a model is picked in its composer. `[models] default` is the route, and magpie does not set it: setting it to `"magpie"` makes the App drop its own sign-in (`ensure_independent_for_custom_route`). The route stays whatever the App had. Pressing Use on magpie under Accounts is what switches it. A magpie that already set the route puts the old one back once, on the next sync or connect (`grokAppReleased`); a Use after that stays. Disconnect drops only the channel, and puts the route back only when it is still `"magpie"`: the one stashed at connect, else the one `connect.was` holds. One of the App's own routes picked in magpie's model field is written as the route and takes magpie's channel out, as picking another provider does elsewhere. A sync with no channel and a route other than `"magpie"` writes nothing, magpie's stash included, and Check says so when the route is `"magpie"` with the channel gone. A model picked in the App's composer since is the user's and stays through a sync, and a sync with nothing to change doesn't write. Shared mode keeps `GROK_HOME` at `~/.grok` (Grok Build's library row). Independent mode, which Use turns on, reads agent-home: the Library writes `AGENTS.md`, `[mcp_servers]` in the same `config.toml`, and `skills/` there, and Grok App also reads `~/.agents/skills`. RTK has no Grok hook, so the Library lists Grok App with the switch off. The notice, while the App runs, says magpie is a custom provider in Settings › Account, a chat can pick its models in the model picker, and the App stays on its current route until Use.
- JSON/JSONC config edits and their previews reject malformed input rather than editing a partially parsed document. Object edits and VS Code's model-group array edits leave the original file untouched on a parse error; valid comments and trailing commas remain supported (`internal/edit`).
- A config that starts with a UTF-8 byte order mark (a Windows `settings.json` or `config.toml` saved by PowerShell, Notepad or a channel switcher, #1534) is read without it (`edit.Read`), and a write keeps it (`keepBOM` in `WriteAtomic`): the user's file keeps the encoding it was saved in. That covers every format `internal/edit` writes (JSON/JSONC and its arrays, TOML, YAML, env); Codex reads a TOML file through a BOM too, so magpie no longer refuses one. A file read some other way trims it with `edit.TrimBOM` (the Claude Code and CC Switch imports). A line an edit takes out of a CRLF file goes with its `\r\n`.
diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.md
index d8c7e97e5..73152789c 100644
--- a/docs/subsystems/gui-shell.md
+++ b/docs/subsystems/gui-shell.md
@@ -405,7 +405,7 @@ covers it in both engines, every language and a narrow window.
- Windows desktop windows and tray panels keep the modal's dimming veil without backdrop blur or saturation: full-window filtering can stall WebView2 while a provider test or sign-in dialog is open. The existing `win` marker from [`layout.js`](../../internal/gui/assets/layout.js) scopes the rule in [`app.css`](../../internal/gui/assets/app.css) to the desktop app; browser pages and other platforms keep their existing effect. `modal-backdrop.test.cjs` checks the computed filter and veil in both engines and modes.
-- Settings → General is laid out as macOS System Settings is (1ooogle on X): a row says its name alone when that says enough (Appearance, Colorblind mode, Language, Text size, the fonts, the tray click, Open at login, Show in Dock), and keeps one short line where the setting isn't clear from its name or has a consequence (Lightweight mode, Prevent sleep, Session terminal). Codex's and Claude Code's own settings (Codex subagents, Long conversations, background compaction, thread titles and descriptions, composer predictions, the auto-review and memories models) aren't here: they are in the agent's opened row on the Agents page (`AGENT_PREFS`, `connectPanel`), the panel's row has a Settings line that opens them in a sheet (`openAgentPrefs`), as does the agent's menu, and Settings' search finds them with a row that opens that sheet (`#agentPrefLinks`). Each row is one element moved between its places, so its handlers and state go with it (the owner, 10-20; `agent-prefs.test.cjs`). Long conversations is the exception with no Codex or Claude Code here, in gateway mode or a magpie in Docker: it sets the windows the gateway serves, which agents on other computers read, so it stays in General (`renderAgentPrefLinks`, Linka on Discord). A font row's line shows only while its fonts load or fail; the text size keys are the choices' tooltip, and Colorblind mode's note is its Off/On control's (`#colorblindSegs`). Colorblind mode (`settings.Colorblind`, `data-colorblind="1"` on `:root`, #2073) switches the chart series (`--c1`…`--c7`) in both light and dark themes to an Okabe–Ito palette where adjacent series differ in hue and lightness. On a quota curve each window (`data-series`, its index mod 7, set by `drawQuotaPlot` and `quotaCurve`'s legend only) gets a dash of its own on `path.qc-line`, its legend key shows a sample of that line (`.qc-sample`) for the dot, and the even paces (`line.qc-even`) are dotted; the curve's tooltip says so. The balance curve sets no `data-series` and keeps its solid line, dashed fit and dot. The Context tab's "good" grade, which takes `--c2` as a colour rather than a series, keeps a blue (`--c1`). Language is one menu button showing the language picked, opened in the app's menu (`renderLangPick`). See `settings-general.test.cjs` and `quota-curve.test.cjs`. Open at login reads `autostart.Enabled`, which on macOS 13 and later also asks Background Task Management about magpie's launch agent (`SMAppService.statusForLegacyURL:`, matched by the plist's Label, not its path); a record the user switched off in System Settings › General › Login Items reads as needing allowing, and the row keeps On with one line saying so and a button that opens Login Items (`/api/open` allows that one `x-apple.systempreferences` URL). The status read again when the window comes back to the front clears the line. On macOS 12, in a build without cgo, or when the system can't be asked, the plist alone decides, as before (#2120, `login-allow.test.cjs`, `login_allow_test.go`).
+- Settings → General is laid out as macOS System Settings is (1ooogle on X): a row says its name alone when that says enough (Appearance, Colorblind mode, Language, Text size, the fonts, the tray click, Open at login, Show in Dock), and keeps one short line where the setting isn't clear from its name or has a consequence (Lightweight mode, Prevent sleep, Session terminal). Codex's, Claude Code's and Grok Build's own settings (Codex subagents, Long conversations, which is all of Grok Build's, background compaction, thread titles and descriptions, composer predictions, the auto-review and memories models) aren't here: they are in the agent's opened row on the Agents page (`AGENT_PREFS`, `connectPanel`), the panel's row has a Settings line that opens them in a sheet (`openAgentPrefs`), as does the agent's menu, and Settings' search finds them with a row that opens that sheet (`#agentPrefLinks`). Each row is one element moved between its places, so its handlers and state go with it (the owner, 10-20; `agent-prefs.test.cjs`). Long conversations is the exception with no Codex, Claude Code or Grok Build here, in gateway mode or a magpie in Docker: it sets the windows the gateway serves, which agents on other computers read, so it stays in General (`renderAgentPrefLinks`, Linka on Discord). A font row's line shows only while its fonts load or fail; the text size keys are the choices' tooltip, and Colorblind mode's note is its Off/On control's (`#colorblindSegs`). Colorblind mode (`settings.Colorblind`, `data-colorblind="1"` on `:root`, #2073) switches the chart series (`--c1`…`--c7`) in both light and dark themes to an Okabe–Ito palette where adjacent series differ in hue and lightness. On a quota curve each window (`data-series`, its index mod 7, set by `drawQuotaPlot` and `quotaCurve`'s legend only) gets a dash of its own on `path.qc-line`, its legend key shows a sample of that line (`.qc-sample`) for the dot, and the even paces (`line.qc-even`) are dotted; the curve's tooltip says so. The balance curve sets no `data-series` and keeps its solid line, dashed fit and dot. The Context tab's "good" grade, which takes `--c2` as a colour rather than a series, keeps a blue (`--c1`). Language is one menu button showing the language picked, opened in the app's menu (`renderLangPick`). See `settings-general.test.cjs` and `quota-curve.test.cjs`. Open at login reads `autostart.Enabled`, which on macOS 13 and later also asks Background Task Management about magpie's launch agent (`SMAppService.statusForLegacyURL:`, matched by the plist's Label, not its path); a record the user switched off in System Settings › General › Login Items reads as needing allowing, and the row keeps On with one line saying so and a button that opens Login Items (`/api/open` allows that one `x-apple.systempreferences` URL). The status read again when the window comes back to the front clears the line. On macOS 12, in a build without cgo, or when the system can't be asked, the plist alone decides, as before (#2120, `login-allow.test.cjs`, `login_allow_test.go`).
- A setting row's line under its name (`.row.pref .sub`, in Settings, Plugins › Built-in and an agent's own settings) wraps whole beside its control, never cut to one line with an ellipsis (arculongus on Discord, `settings-lines-wrap.test.cjs`).
- Settings' search-provider picker offers **Off**, saved as `searcher: "off"`. Its help explains API-only search and suppresses provider fallback/own-search hints while off; the search priority row is hidden because no provider competes with the APIs. See [gateway search behavior](gateway-routing.md#turning-provider-search-off), [`renderSearcher`](../../internal/gui/assets/app.js), `TestSettingsSearchProviderOff` and `searcher-pick.test.cjs`.
- Settings' search APIs are asked in their listed order: each API's row (with its keys' row) is dragged as one, or moved with Alt+↑/↓, and has a switch that turns it off without removing its key (#2286). See [the search APIs' order](gateway-routing.md#the-search-apis-order-and-one-switched-off), `searchArrange` in [`app.js`](../../internal/gui/assets/app.js) and `search-order.test.cjs`.
diff --git a/internal/agent/grok.go b/internal/agent/grok.go
index 07ca1a3d0..648a49e14 100644
--- a/internal/agent/grok.go
+++ b/internal/agent/grok.go
@@ -16,17 +16,23 @@ package agent
// gives them back.
import (
+ "encoding/json"
+ "errors"
+ "io/fs"
+ "maps"
"os"
"path/filepath"
"slices"
"strconv"
"strings"
+ toml "github.com/pelletier/go-toml/v2"
"github.com/tidwall/gjson"
"github.com/yetone/magpie/internal/catalog"
"github.com/yetone/magpie/internal/edit"
"github.com/yetone/magpie/internal/provider"
+ "github.com/yetone/magpie/internal/settings"
)
// grokEfforts are the reasoning efforts Grok knows.
@@ -36,9 +42,14 @@ var grokEfforts = []string{"none", "minimal", "low", "medium", "high", "xhigh",
var grokModelTable = `model."` + magpieID + "/"
// grokModelTables are magpie's model tables, for a Grok that reaches the
-// gateway's /v1 at v1.
-func grokModelTables(v1 string) []edit.Table {
+// gateway's /v1 at v1, and the context_window magpie gives each model (by
+// its catalog id), which the caller stashes. A context_window the user set
+// in a table themselves (grokOwnWindow: had is what the tables hold now,
+// wrote what magpie last gave them, nil before magpie kept a record) stays
+// as they set it.
+func grokModelTables(v1 string, had, wrote map[string]int) ([]edit.Table, map[string]int) {
var out []edit.Table
+ st, gave := settings.Load(), map[string]int{}
for _, m := range magpieModels("grok") {
kvs := []edit.KV{
{Path: "model", Value: m.ID},
@@ -47,8 +58,12 @@ func grokModelTables(v1 string) []edit.Table {
{Path: "api_key", Value: keyAt(v1)},
{Path: "api_backend", Value: grokBackend(m)},
}
- if m.Context > 0 {
- kvs = append(kvs, edit.KV{Path: "context_window", Value: m.Context})
+ if w := grokWindow(st, m); w > 0 {
+ gave[m.ID] = w
+ if n, ok := grokOwnWindow(m, w, had, wrote); ok {
+ w = n
+ }
+ kvs = append(kvs, edit.KV{Path: "context_window", Value: w})
}
var efforts []string
for _, e := range grokEfforts { // in Grok's order
@@ -61,7 +76,71 @@ func grokModelTables(v1 string) []edit.Table {
}
out = append(out, edit.Table{Name: "model." + strconv.Quote(magpieID+"/"+m.ID), KVs: kvs})
}
- return out
+ return out, gave
+}
+
+// grokWindow is the context_window Grok Build is told for m. Grok Build
+// auto-compacts by it ("drives auto-compact timing", its config reference),
+// so it is where Long conversations has Codex and Claude Code compact
+// (codexcat's rule): the threshold set on the model or its provider, else
+// settings' working window on a longer one, and the whole window under
+// Full window (uk.jent on Discord: dozens of models told 1M, each set to
+// 300K by hand). 0 when m's window isn't known.
+func grokWindow(st settings.Settings, m catalog.Model) int {
+ c := m.Context
+ if c <= 0 {
+ return 0
+ }
+ if m.Compact > 0 {
+ return min(c, m.Compact)
+ }
+ return st.Working(c)
+}
+
+// grokOwnWindow is a context_window the user set in magpie's table for m
+// themselves, which a sync keeps: one other than magpie last gave it. With
+// no record of magpie's (wrote nil, a config an older magpie wrote, or a
+// model new to the record), one other than the model's whole window, which
+// an older magpie wrote, and other than w, which magpie gives it now.
+func grokOwnWindow(m catalog.Model, w int, had, wrote map[string]int) (int, bool) {
+ n, ok := had[m.ID]
+ if !ok || n <= 0 || n == w {
+ return 0, false
+ }
+ if prev, ok := wrote[m.ID]; ok {
+ return n, n != prev
+ }
+ return n, n != m.Context
+}
+
+// grokWindowsIn is the context_window of each of magpie's model tables in
+// the config at path, by catalog id. A config that isn't there has none; one
+// that doesn't parse is an error, so a sync writes nothing over it.
+func grokWindowsIn(path string) (map[string]int, error) {
+ b, err := os.ReadFile(path)
+ if errors.Is(err, fs.ErrNotExist) {
+ return nil, nil
+ }
+ if err != nil {
+ return nil, err
+ }
+ var doc struct {
+ Model map[string]map[string]any `toml:"model"`
+ }
+ if err := toml.Unmarshal(b, &doc); err != nil {
+ return nil, err
+ }
+ out := map[string]int{}
+ for name, t := range doc.Model {
+ id, ok := strings.CutPrefix(name, magpieID+"/")
+ if !ok {
+ continue
+ }
+ if n, ok := t["context_window"].(int64); ok {
+ out[id] = int(n)
+ }
+ }
+ return out, nil
}
// grokBackend is the api_backend a model of magpie's is asked on: the API
@@ -108,8 +187,36 @@ func grokIn(at place) *Agent {
}
return false, nil
}
- writeMagpie := func() error { return edit.SetTOMLTables(path, []string{grokModelTable}, grokModelTables(at.v1())) }
- dropMagpie := func() error { return edit.SetTOMLTables(path, []string{grokModelTable}, nil) }
+ // keyWindows is the context_window magpie last gave each of its models,
+ // so one the user set by hand since is told from it and kept
+ keyWindows := "grok:" + path + ":windows"
+ writeMagpie := func() error {
+ had, err := grokWindowsIn(path)
+ if err != nil {
+ return err
+ }
+ var wrote map[string]int
+ saved := stashLoad()[keyWindows]
+ if saved != "" {
+ json.Unmarshal([]byte(saved), &wrote)
+ }
+ tables, gave := grokModelTables(at.v1(), had, wrote)
+ if err := edit.SetTOMLTables(path, []string{grokModelTable}, tables); err != nil {
+ return err
+ }
+ if !maps.Equal(gave, wrote) || saved == "" {
+ b, _ := json.Marshal(gave)
+ stash(map[string]string{keyWindows: string(b)})
+ }
+ return nil
+ }
+ dropMagpie := func() error {
+ if err := edit.SetTOMLTables(path, []string{grokModelTable}, nil); err != nil {
+ return err
+ }
+ forget(keyWindows)
+ return nil
+ }
// the default model is the user's, not a campaign's
ownDefault := func(features map[string]string) error {
if features["campaigns"] == "false" {
diff --git a/internal/agent/grok_test.go b/internal/agent/grok_test.go
index 5550b8fee..43ca2433e 100644
--- a/internal/agent/grok_test.go
+++ b/internal/agent/grok_test.go
@@ -295,3 +295,141 @@ func TestGrokAsksEachModelNatively(t *testing.T) {
}
}
}
+
+// grokSandbox is a sandbox HOME with a DeepSeek of a 1M and a 200K model,
+// windows the user typed, and the path of Grok Build's config there.
+func grokSandbox(t *testing.T) (string, string) {
+ t.Helper()
+ home := t.TempDir()
+ t.Setenv("HOME", home)
+ t.Setenv("USERPROFILE", home)
+ t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
+ t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
+ t.Setenv("GROK_HOME", filepath.Join(home, "grok"))
+ if err := provider.Save(provider.Provider{ID: "deepseek", Name: "DeepSeek", Chat: "http://127.0.0.1:1/v1", Key: "k", Models: []string{"pro", "flash"},
+ Contexts: map[string]int{"pro": 1000000, "flash": 200000}}); err != nil {
+ t.Fatal(err)
+ }
+ return home, filepath.Join(home, "grok", "config.toml")
+}
+
+// grokWindows is the context_window of magpie's tables for pro and flash.
+func grokWindows(t *testing.T, path string) (int, int) {
+ t.Helper()
+ got, err := grokWindowsIn(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return got["deepseek/pro"], got["deepseek/flash"]
+}
+
+// A context_window the user set by hand in one of magpie's tables stays
+// through a sync and a new pick (uk.jent on Discord: dozens of models told
+// 1M, set to 300K one by one, and written over on the next sync), while
+// the tables they didn't touch follow magpie's catalog.
+func TestGrokKeepsAWindowSetByHand(t *testing.T) {
+ home, path := grokSandbox(t)
+ a := grok(home)
+ if err := a.Field("model").Set("magpie/deepseek/pro"); err != nil {
+ t.Fatal(err)
+ }
+ if pro, flash := grokWindows(t, path); pro != 1000000 || flash != 200000 {
+ t.Fatalf("magpie's windows: pro %d, flash %d", pro, flash)
+ }
+ if err := edit.SetTOMLKey(path, `model."magpie/deepseek/pro"`, "context_window", 300000); err != nil {
+ t.Fatal(err)
+ }
+ if err := a.Sync(); err != nil {
+ t.Fatal(err)
+ }
+ if err := a.Field("model").Set("magpie/deepseek/flash"); err != nil {
+ t.Fatal(err)
+ }
+ if pro, flash := grokWindows(t, path); pro != 300000 || flash != 200000 {
+ raw, _ := os.ReadFile(path)
+ t.Fatalf("after a sync: pro %d (set by hand to 300000), flash %d\n%s", pro, flash, raw)
+ }
+ // the provider's window changed in magpie: the one set by hand stays,
+ // the other follows
+ provider.Save(provider.Provider{ID: "deepseek", Name: "DeepSeek", Chat: "http://127.0.0.1:1/v1", Key: "k", Models: []string{"pro", "flash"},
+ Contexts: map[string]int{"pro": 1000000, "flash": 128000}})
+ if err := a.Sync(); err != nil {
+ t.Fatal(err)
+ }
+ if pro, flash := grokWindows(t, path); pro != 300000 || flash != 128000 {
+ t.Fatalf("after a window changed: pro %d, flash %d", pro, flash)
+ }
+ // taken out and put back, magpie's tables start from its own again
+ if err := a.Field("model").Set(""); err != nil {
+ t.Fatal(err)
+ }
+ if err := a.Field("model").Set("magpie/deepseek/pro"); err != nil {
+ t.Fatal(err)
+ }
+ if pro, _ := grokWindows(t, path); pro != 1000000 {
+ t.Fatalf("connected again: pro %d", pro)
+ }
+}
+
+// A config an older magpie wrote, with no record of what it gave: a window
+// other than the model's whole one is the user's and stays; the whole one,
+// which that magpie wrote, follows Long conversations.
+func TestGrokKeepsAWindowSetBeforeTheRecord(t *testing.T) {
+ home, path := grokSandbox(t)
+ os.MkdirAll(filepath.Dir(path), 0o755)
+ old := "[models]\ndefault = \"magpie/deepseek/pro\"\n\n" +
+ "[model.\"magpie/deepseek/pro\"]\nmodel = \"deepseek/pro\"\nbase_url = \"http://127.0.0.1:3425/v1\"\napi_key = \"magpie\"\ncontext_window = 300000\n\n" +
+ "[model.\"magpie/deepseek/flash\"]\nmodel = \"deepseek/flash\"\nbase_url = \"http://127.0.0.1:3425/v1\"\napi_key = \"magpie\"\ncontext_window = 200000\n"
+ if err := os.WriteFile(path, []byte(old), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ s := settings.Load()
+ s.CompactAt = 150000
+ if err := settings.Save(s); err != nil {
+ t.Fatal(err)
+ }
+ if err := grok(home).Sync(); err != nil {
+ t.Fatal(err)
+ }
+ if pro, flash := grokWindows(t, path); pro != 300000 || flash != 150000 {
+ raw, _ := os.ReadFile(path)
+ t.Fatalf("pro %d (the user's 300000), flash %d (Long conversations' 150000)\n%s", pro, flash, raw)
+ }
+}
+
+// Grok Build compacts by context_window, so it is told where Long
+// conversations has Codex and Claude Code compact: the size typed there
+// on a longer window, the whole window under Full window, and a threshold
+// set on the model in its provider before either.
+func TestGrokWindowFollowsLongConversations(t *testing.T) {
+ home, path := grokSandbox(t)
+ a := grok(home)
+ if err := a.Field("model").Set("magpie/deepseek/pro"); err != nil {
+ t.Fatal(err)
+ }
+ set := func(f func(*settings.Settings)) {
+ t.Helper()
+ s := settings.Load()
+ f(&s)
+ if err := settings.Save(s); err != nil {
+ t.Fatal(err)
+ }
+ if err := a.Sync(); err != nil {
+ t.Fatal(err)
+ }
+ }
+ set(func(s *settings.Settings) { s.CompactAt = 300000 })
+ if pro, flash := grokWindows(t, path); pro != 300000 || flash != 200000 {
+ t.Fatalf("compact at 300K: pro %d, flash %d", pro, flash)
+ }
+ set(func(s *settings.Settings) { s.FullContext = true })
+ if pro, flash := grokWindows(t, path); pro != 1000000 || flash != 200000 {
+ t.Fatalf("full window: pro %d, flash %d", pro, flash)
+ }
+ set(func(s *settings.Settings) {
+ s.FullContext, s.ModelCompacts = false, map[string]int{"deepseek/pro": 400000}
+ })
+ if pro, flash := grokWindows(t, path); pro != 400000 || flash != 200000 {
+ t.Fatalf("pro's own threshold: pro %d, flash %d", pro, flash)
+ }
+}
diff --git a/internal/cli/model_cli.go b/internal/cli/model_cli.go
index ed32d5c9b..06c78ba77 100644
--- a/internal/cli/model_cli.go
+++ b/internal/cli/model_cli.go
@@ -82,12 +82,13 @@ const modelUsage = `usage:
own, a name you gave a model just as you wrote it, "Opus 5.5",
the others as on; off, "Sol" alone — but two a list would name
the same keep it
- magpie model compact [on|off|<size>] whether Codex and Claude Code compact a long conversation at
- 272K: on, as by default, for a model of a longer window (in
- Claude Code, a Claude model runs to its own); off, at the
- model's whole window, 1M for a [1m] one; a size such as 500k
- compacts there instead. The app's Long conversations,
- in Codex's and Claude Code's settings on the Agents page,
+ magpie model compact [on|off|<size>] whether Codex, Claude Code and Grok Build compact a long
+ conversation at 272K: on, as by default, for a model of a
+ longer window (in Claude Code, a Claude model runs to its
+ own); off, at the model's whole window, 1M for a [1m] one; a
+ size such as 500k compacts there instead. The app's Long
+ conversations, in Codex's, Claude Code's and Grok Build's
+ settings on the Agents page,
is the same switch; a provider's own Compact at (its
editor) comes before it
@@ -688,9 +689,9 @@ func modelSuffix(args []string) error {
func modelCompact(args []string) error {
if len(args) == 0 {
if s := settings.Load(); s.FullContext {
- fmt.Println("off", muted.Render("· Codex and Claude Code run a conversation to the model's whole window · magpie model compact on"))
+ fmt.Println("off", muted.Render("· Codex, Claude Code and Grok Build run a conversation to the model's whole window · magpie model compact on"))
} else {
- fmt.Println("on", muted.Render(fmt.Sprintf("· Codex and Claude Code compact at %dK on a longer window; in Claude Code a Claude model runs to its own · magpie model compact off", s.Compact()/1000)))
+ fmt.Println("on", muted.Render(fmt.Sprintf("· Codex, Claude Code and Grok Build compact at %dK on a longer window; in Claude Code a Claude model runs to its own · magpie model compact off", s.Compact()/1000)))
}
return nil
}
@@ -707,16 +708,16 @@ func modelCompact(args []string) error {
if err := provider.SetCompactAt(n); err != nil {
return err
}
- fmt.Println(green.Render("✓"), fmt.Sprintf("Codex and Claude Code compact at %dK on a longer window", settings.Load().Compact()/1000))
+ fmt.Println(green.Render("✓"), fmt.Sprintf("Codex, Claude Code and Grok Build compact at %dK on a longer window", settings.Load().Compact()/1000))
return nil
}
if err := provider.SetFullContext(full); err != nil {
return err
}
if full {
- fmt.Println(green.Render("✓"), "Codex and Claude Code run a conversation to the model's whole window", muted.Render("· every turn sends all of it"))
+ fmt.Println(green.Render("✓"), "Codex, Claude Code and Grok Build run a conversation to the model's whole window", muted.Render("· every turn sends all of it"))
} else {
- fmt.Println(green.Render("✓"), fmt.Sprintf("Codex and Claude Code compact at %dK again", settings.Load().Compact()/1000))
+ fmt.Println(green.Render("✓"), fmt.Sprintf("Codex, Claude Code and Grok Build compact at %dK again", settings.Load().Compact()/1000))
}
return nil
}
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index 93ae080ad..d6464874c 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -10120,7 +10120,7 @@ function compactField() {
light();
const wrap = el("div", "cxfield");
wrap.append(cp, row);
- return field(t("Compact at"), wrap, t("Where Codex and Claude Code compact a long conversation on these models; empty follows Long conversations, in their settings on the Agents page (else in Settings), and a size at or above a model's window runs it to its whole window"));
+ return field(t("Compact at"), wrap, t("Where Codex, Claude Code and Grok Build compact a long conversation on these models; empty follows Long conversations, in their settings on the Agents page (else in Settings), and a size at or above a model's window runs it to its whole window"));
}
function compactError(ed, v) {
@@ -20860,10 +20860,11 @@ function renderAlerts(s, keep) {
// AGENT_PREFS: an agent's own settings, by its id, each a row kept in
// #agentPrefRows and shown in the agent's sheet (openAgentPrefs). They sat
// in Settings, apart from the agents they set (the owner, 10-20); Long
-// conversations is Codex's and Claude Code's both, in each one's sheet.
+// conversations is Codex's, Claude Code's and Grok Build's (uk.jent), in each one's sheet.
const AGENT_PREFS = {
codex: ["codexAgentsV1Row", "codexSubagentModelRow", "fullContextRow", "codexAsyncRow", "codexTitlesRow", "codexDescriptionsRow", "codexPredictionsRow", "codexAutoReviewRow", "codexMemoriesRow"],
claude: ["fullContextRow"],
+ grok: ["fullContextRow"],
};
const agentPrefsOf = (a) => gatewayMode ? null : AGENT_PREFS[a.id.split("@wsl:")[0]];
const PREFS_GLYPH = "M2.75 4.75h10.5M2.75 11.25h10.5M5.75 3.25v3M10.25 9.75v3";
@@ -20925,7 +20926,7 @@ function renderAgentPrefs() {
// 70–90s to a first token at 550K)
// at a size the user types too, not 272K alone (#876); a provider's own
// Compact at comes before either
- const setCompact = (body) => writingPrefs(api("settings/full-context", body)).then((ns) => { prefs = ns; renderSettings(); }).catch((e) => { status(t(e.message), "err"); renderSettings(); });
+ const setCompact = (body) => prefWrite(api("settings/full-context", body));
const at = contextsText({ "*": s.compactAt || 272000 });
const compactSegs = segs([["off", t("Compact at {n}", { n: at.toUpperCase() })], ["on", t("Full window")]], s.fullContext ? "on" : "off", (v) => setCompact({ on: v === "on" }));
const compactNum = input(s.compactAt ? at : "", "272k");
@@ -20944,7 +20945,7 @@ function renderAgentPrefs() {
$("#fullContextSegs").replaceChildren(compactRow);
// Codex's background compaction (#2490): [features.async_compaction] and
// its threshold, written where magpie routes Codex (codex_async.go)
- const setAsync = (body) => writingPrefs(api("settings/codex-async-compact", body)).then((ns) => { prefs = ns; renderSettings(); }).catch((e) => { status(t(e.message), "err"); renderSettings(); });
+ const setAsync = (body) => prefWrite(api("settings/codex-async-compact", body));
const asyncSegs = segs([["off", t("Off")], ["on", t("On")]], s.codexAsyncCompact ? "on" : "off", (v) => setAsync({ on: v === "on" }));
const asyncNum = input(s.codexAsyncCompactPercent ? s.codexAsyncCompactPercent + "%" : "", "65%");
asyncNum.className = "words compact-num";
diff --git a/internal/gui/assets/context.js b/internal/gui/assets/context.js
index d0362f9f0..6c31c8457 100644
--- a/internal/gui/assets/context.js
+++ b/internal/gui/assets/context.js
@@ -1484,7 +1484,7 @@
const note = el("div", "ctx-tune-src");
title.after(note);
if (set.locked) note.textContent = t("{name} is set and comes first", { name: set.locked });
- else if (set.source == "long") note.textContent = t("Long conversations, shared by Codex and Claude Code");
+ else if (set.source == "long") note.textContent = t("Long conversations, shared by Codex, Claude Code and Grok Build");
else if (set.ours) note.textContent = t("Set by magpie");
else if (set.value && a.compact && +set.value > a.compact.window && a.compact.window) note.textContent = t("You set {value}; the model's {window} comes first", { value: show(set.value), window: fmtK(a.compact.window) });
else if (set.value) note.textContent = t("You set {value}", { value: show(set.value) });
diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js
index e1fdf10ad..bc3c7b620 100644
--- a/internal/gui/assets/i18n.js
+++ b/internal/gui/assets/i18n.js
@@ -143,7 +143,7 @@ const I18N = {
"Put back": "已恢复",
"Use {value}": "使用 {value}",
"Replaces your {value}; Undo puts it back": "会替换你的 {value};撤销可恢复",
- "Long conversations, shared by Codex and Claude Code": "「长对话」,Codex 和 Claude Code 共用",
+ "Long conversations, shared by Codex, Claude Code and Grok Build": "「长对话」,Codex、Claude Code 和 Grok Build 共用",
"1 call": "1 次调用",
"Up to {pct} fewer": "最多少 {pct}",
"Not enough calls in this range to tune on": "这段时间的调用太少,还算不出建议",
@@ -1067,7 +1067,7 @@ const I18N = {
"Codex app": "Codex 应用",
"Codex editor extension": "编辑器里的 Codex 扩展",
"Codex in WSL": "WSL 里的 Codex",
- "Codex and Claude Code compact at 272K (non-Claude [1m] too) or the size typed; full window: slower, costlier": "Codex 和 Claude Code 在 272K(非 Claude 的 [1m] 模型也是)或这里填的大小时压缩;完整窗口每轮更慢更贵",
+ "Codex, Claude Code and Grok Build compact at 272K (non-Claude [1m] too) or the size typed; full window: slower, costlier": "Codex、Claude Code 和 Grok Build 在 272K(非 Claude 的 [1m] 模型也是)或这里填的大小时压缩;完整窗口每轮更慢更贵",
"Compact at {n}": "{n} 时压缩",
"Codex thread titles": "Codex 会话标题",
"Codex thread descriptions": "Codex 会话描述",
@@ -1541,7 +1541,7 @@ const I18N = {
"Max output: {v} is not a number of tokens like 32k": "最大输出:{v} 不是 32k 这样的 token 数",
"Compact at": "压缩阈值",
"e.g. 500k · or deepseek-v4-flash=272k, comma separated": "如 500k · 或 deepseek-v4-flash=272k,逗号分隔",
- "Where Codex and Claude Code compact a long conversation on these models; empty follows Long conversations, in their settings on the Agents page (else in Settings), and a size at or above a model's window runs it to its whole window": "Codex 和 Claude Code 在这些模型上压缩长对话的位置;留空按 Agent 页里它们设置中的「长对话」(否则在「设置」里),大于等于模型窗口则用完整窗口",
+ "Where Codex, Claude Code and Grok Build compact a long conversation on these models; empty follows Long conversations, in their settings on the Agents page (else in Settings), and a size at or above a model's window runs it to its whole window": "Codex、Claude Code 和 Grok Build 在这些模型上压缩长对话的位置;留空按 Agent 页里它们设置中的「长对话」(否则在「设置」里),大于等于模型窗口则用完整窗口",
"Compact at: {v} is not a number of tokens like 272k": "压缩阈值:{v} 不是 272k 这样的 token 数",
"add a model: filter, or type provider/model…": "添加模型:筛选,或输入 provider/model…",
"No provider serves {id} now; it is skipped": "现在没有供应商提供 {id},会跳过它",
@@ -4206,7 +4206,7 @@ const I18N = {
"Put back": "已復原",
"Use {value}": "使用 {value}",
"Replaces your {value}; Undo puts it back": "會取代你的 {value};復原可還原",
- "Long conversations, shared by Codex and Claude Code": "「長對話」,Codex 與 Claude Code 共用",
+ "Long conversations, shared by Codex, Claude Code and Grok Build": "「長對話」,Codex、Claude Code 與 Grok Build 共用",
"1 call": "1 次呼叫",
"Up to {pct} fewer": "最多少 {pct}",
"Not enough calls in this range to tune on": "這段時間的呼叫太少,還算不出建議",
@@ -5126,7 +5126,7 @@ const I18N = {
"Codex app": "Codex 應用程式",
"Codex editor extension": "編輯器裡的 Codex 擴充功能",
"Codex in WSL": "WSL 裡的 Codex",
- "Codex and Claude Code compact at 272K (non-Claude [1m] too) or the size typed; full window: slower, costlier": "Codex 和 Claude Code 在 272K(非 Claude 的 [1m] 模型也是)或這裡填的大小時壓縮;完整視窗每輪更慢更貴",
+ "Codex, Claude Code and Grok Build compact at 272K (non-Claude [1m] too) or the size typed; full window: slower, costlier": "Codex、Claude Code 和 Grok Build 在 272K(非 Claude 的 [1m] 模型也是)或這裡填的大小時壓縮;完整視窗每輪更慢更貴",
"Compact at {n}": "{n} 時壓縮",
"Codex thread titles": "Codex 會話標題",
"as Codex sends them when the session is on Codex’s own model": "工作階段在 Codex 自帶模型上時按 Codex 原樣傳送",
@@ -5589,7 +5589,7 @@ const I18N = {
"Max output: {v} is not a number of tokens like 32k": "最大輸出:{v} 不是 32k 這樣的 token 數",
"Compact at": "壓縮閾值",
"e.g. 500k · or deepseek-v4-flash=272k, comma separated": "如 500k · 或 deepseek-v4-flash=272k,逗號分隔",
- "Where Codex and Claude Code compact a long conversation on these models; empty follows Long conversations, in their settings on the Agents page (else in Settings), and a size at or above a model's window runs it to its whole window": "Codex 和 Claude Code 在這些模型上壓縮長對話的位置;留空按 Agent 頁裡它們設定中的「長對話」(否則在「設定」裡),大於等於模型視窗則用完整視窗",
+ "Where Codex, Claude Code and Grok Build compact a long conversation on these models; empty follows Long conversations, in their settings on the Agents page (else in Settings), and a size at or above a model's window runs it to its whole window": "Codex、Claude Code 和 Grok Build 在這些模型上壓縮長對話的位置;留空按 Agent 頁裡它們設定中的「長對話」(否則在「設定」裡),大於等於模型視窗則用完整視窗",
"Compact at: {v} is not a number of tokens like 272k": "壓縮閾值:{v} 不是 272k 這樣的 token 數",
"add a model: filter, or type provider/model…": "新增模型:篩選,或輸入 provider/model…",
"No provider serves {id} now; it is skipped": "現在沒有供應商提供 {id},會跳過它",
@@ -8244,7 +8244,7 @@ const I18N = {
"Put back": "元に戻しました",
"Use {value}": "{value} にする",
"Replaces your {value}; Undo puts it back": "あなたの {value} を置き換えます。取り消すと戻ります",
- "Long conversations, shared by Codex and Claude Code": "「長い会話」。Codex と Claude Code で共通",
+ "Long conversations, shared by Codex, Claude Code and Grok Build": "「長い会話」。Codex、Claude Code、Grok Build で共通",
"1 call": "1 回の呼び出し",
"Up to {pct} fewer": "最大 {pct} 減",
"Not enough calls in this range to tune on": "この期間は呼び出しが少なく、まだ調整できません",
@@ -9147,7 +9147,7 @@ const I18N = {
"Codex app": "Codex アプリ",
"Codex editor extension": "エディタの Codex 拡張機能",
"Codex in WSL": "WSL の Codex",
- "Codex and Claude Code compact at 272K (non-Claude [1m] too) or the size typed; full window: slower, costlier": "Codex と Claude Code は 272K(Claude 以外の [1m] モデルも)か入力したサイズで圧縮。ウィンドウ全体は遅く高価",
+ "Codex, Claude Code and Grok Build compact at 272K (non-Claude [1m] too) or the size typed; full window: slower, costlier": "Codex、Claude Code、Grok Build は 272K(Claude 以外の [1m] モデルも)か入力したサイズで圧縮。ウィンドウ全体は遅く高価",
"Compact at {n}": "{n} で圧縮",
"Codex thread titles": "Codex のスレッドタイトル",
"Codex thread descriptions": "Codex のスレッド説明",
@@ -9614,7 +9614,7 @@ const I18N = {
"Max output: {v} is not a number of tokens like 32k": "最大出力:{v} は 32k のようなトークン数ではありません",
"Compact at": "圧縮しきい値",
"e.g. 500k · or deepseek-v4-flash=272k, comma separated": "例:500k · または deepseek-v4-flash=272k(カンマ区切り)",
- "Where Codex and Claude Code compact a long conversation on these models; empty follows Long conversations, in their settings on the Agents page (else in Settings), and a size at or above a model's window runs it to its whole window": "Codex と Claude Code がこれらのモデルで長い会話を圧縮する位置です。空欄ならエージェントページのそれぞれの設定にある「長い会話」(なければ「設定」)に従い、モデルのウィンドウ以上ならウィンドウ全体を使います",
+ "Where Codex, Claude Code and Grok Build compact a long conversation on these models; empty follows Long conversations, in their settings on the Agents page (else in Settings), and a size at or above a model's window runs it to its whole window": "Codex、Claude Code、Grok Build がこれらのモデルで長い会話を圧縮する位置です。空欄ならエージェントページのそれぞれの設定にある「長い会話」(なければ「設定」)に従い、モデルのウィンドウ以上ならウィンドウ全体を使います",
"Compact at: {v} is not a number of tokens like 272k": "圧縮しきい値:{v} は 272k のようなトークン数ではありません",
"add a model: filter, or type provider/model…": "モデルを追加:絞り込み、または provider/model を入力…",
"No provider serves {id} now; it is skipped": "現在 {id} を提供しているプロバイダはないため、スキップされます",
@@ -12289,7 +12289,7 @@ const I18N = {
"Put back": "Zurückgesetzt",
"Use {value}": "{value} verwenden",
"Replaces your {value}; Undo puts it back": "Ersetzt dein {value}; Rückgängig stellt es wieder her",
- "Long conversations, shared by Codex and Claude Code": "„Lange Unterhaltungen“, die Codex und Claude Code teilen",
+ "Long conversations, shared by Codex, Claude Code and Grok Build": "„Lange Unterhaltungen“, die Codex, Claude Code und Grok Build teilen",
"1 call": "1 Aufruf",
"Up to {pct} fewer": "Bis zu {pct} weniger",
"Not enough calls in this range to tune on": "Zu wenige Aufrufe in diesem Zeitraum zum Abstimmen",
@@ -13202,7 +13202,7 @@ const I18N = {
"Codex app": "Codex-App",
"Codex editor extension": "Codex-Erweiterung im Editor",
"Codex in WSL": "Codex in WSL",
- "Codex and Claude Code compact at 272K (non-Claude [1m] too) or the size typed; full window: slower, costlier": "Codex/Claude Code komprimieren bei 272K (auch [1m] außer Claude) oder hier; volles Fenster: teurer",
+ "Codex, Claude Code and Grok Build compact at 272K (non-Claude [1m] too) or the size typed; full window: slower, costlier": "Codex/Claude Code/Grok Build komprimieren bei 272K (auch [1m] außer Claude) oder hier; volles Fenster: teurer",
"Compact at {n}": "Bei {n} komprimieren",
"Codex thread titles": "Codex-Thread-Titel",
"Codex thread descriptions": "Codex-Thread-Beschreibungen",
@@ -13669,7 +13669,7 @@ const I18N = {
"Max output: {v} is not a number of tokens like 32k": "Max. Ausgabe: {v} ist keine Token-Zahl wie 32k",
"Compact at": "Komprimieren ab",
"e.g. 500k · or deepseek-v4-flash=272k, comma separated": "z. B. 500k · oder deepseek-v4-flash=272k, durch Kommas getrennt",
- "Where Codex and Claude Code compact a long conversation on these models; empty follows Long conversations, in their settings on the Agents page (else in Settings), and a size at or above a model's window runs it to its whole window": "Wo Codex und Claude Code eine lange Unterhaltung bei diesen Modellen komprimieren; leer folgt Lange Unterhaltungen in ihren Einstellungen auf der Seite Agenten (sonst unter Einstellungen), ein Wert ab dem Fenster des Modells nutzt das ganze Fenster",
+ "Where Codex, Claude Code and Grok Build compact a long conversation on these models; empty follows Long conversations, in their settings on the Agents page (else in Settings), and a size at or above a model's window runs it to its whole window": "Wo Codex, Claude Code und Grok Build eine lange Unterhaltung bei diesen Modellen komprimieren; leer folgt Lange Unterhaltungen in ihren Einstellungen auf der Seite Agenten (sonst unter Einstellungen), ein Wert ab dem Fenster des Modells nutzt das ganze Fenster",
"Compact at: {v} is not a number of tokens like 272k": "Komprimieren ab: {v} ist keine Token-Zahl wie 272k",
"add a model: filter, or type provider/model…": "Modell hinzufügen: filtern oder provider/model eingeben…",
"No provider serves {id} now; it is skipped": "Derzeit stellt kein Anbieter {id} bereit; es wird übersprungen",
diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.html
index 55a44f3a8..56f7817fb 100644
--- a/internal/gui/assets/index.html
+++ b/internal/gui/assets/index.html
@@ -467,7 +467,7 @@
<div class="val" id="codexSubagentModelPick"></div>
</div>
<div class="row pref" id="fullContextRow">
- <div class="who"><div class="name" data-t>Long conversations</div><div class="sub" data-t>Codex and Claude Code compact at 272K (non-Claude [1m] too) or the size typed; full window: slower, costlier</div></div>
+ <div class="who"><div class="name" data-t>Long conversations</div><div class="sub" data-t>Codex, Claude Code and Grok Build compact at 272K (non-Claude [1m] too) or the size typed; full window: slower, costlier</div></div>
<div id="fullContextSegs"></div>
</div>
<div class="row pref" id="codexAsyncRow">
diff --git a/internal/gui/tests/agent-prefs.test.cjs b/internal/gui/tests/agent-prefs.test.cjs
index 1b4243ee8..8cee68cf8 100644
--- a/internal/gui/tests/agent-prefs.test.cjs
+++ b/internal/gui/tests/agent-prefs.test.cjs
@@ -2,7 +2,8 @@
// An agent's own settings are where the agent is (the owner, 10-20: Codex's
// and Claude Code's rows sat in Settings › General, apart from the agents
// they set). In the window, Codex's opened row holds its eight and Claude
-// Code's its one, Long conversations; Settings has none of them, but its
+// Code's and Grok Build's their one, Long conversations (Grok Build's since
+// uk.jent on Discord: its context_window is where it compacts); Settings has none of them, but its
// search still finds them, as a row saying where they are whose Open shows
// the agent's sheet. In the panel a "Settings" line opens the sheet, and so
// does the agent's menu; shut, the rows are back where they were. Gateway
@@ -45,7 +46,7 @@ function server(lang, { gateway = false, none = false, posts = [] } = {}) {
const json = (data) => route.fulfill({ json: data });
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:${gateway}${gateway ? ",gateway:true" : ""}};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
- if (url.pathname === "/api/state") return json({ agents: none ? [agentRow("pi", "Pi")] : [codex, agentRow("claude", "Claude Code"), agentRow("pi", "Pi")], profiles: [], settings: { lang, theme: "light" }, fx: settings.fx });
+ if (url.pathname === "/api/state") return json({ agents: none ? [agentRow("pi", "Pi")] : [codex, agentRow("claude", "Claude Code"), { ...agentRow("grok", "Grok Build"), icon: "xai" }, agentRow("pi", "Pi")], profiles: [], settings: { lang, theme: "light" }, fx: settings.fx });
if (url.pathname === "/api/settings/full-context") {
const body = route.request().postDataJSON();
posts.push(body);
@@ -106,6 +107,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await noSideScroll(page, `${lang} ${width} Codex`);
await openAgentSettings(page, "claude");
assert.deepEqual(await shownIn(page, '.row.agent[data-id="claude"] .ag-prefs'), ["fullContextRow"], `${lang} ${width}: Claude Code's one`);
+ // Grok Build's one, Long conversations, whose line names it
+ await openAgentSettings(page, "grok");
+ const grokBox = '.row.agent[data-id="grok"] .ag-prefs';
+ assert.deepEqual(await shownIn(page, grokBox), ["fullContextRow"], `${lang} ${width}: Grok Build's one`);
+ assert.match(await page.locator(`${grokBox} #fullContextRow .sub`).textContent(), /Grok Build/, `${lang}: the line names Grok Build`);
+ assert(await page.locator(grokBox).evaluate((b) => b.scrollWidth <= b.clientWidth + 1), `${lang} ${width}: Grok Build's row fits`);
+ await noSideScroll(page, `${lang} ${width} Grok Build`);
// none in Settings; its search says where they are
await page.goto("http://magpie.test/?view=settings");
@@ -153,6 +161,14 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.deepEqual(await shownIn(page, "#modal .editor.agent-prefs"), ["fullContextRow"]);
await page.keyboard.press("Escape");
await page.locator("#modal").waitFor({ state: "hidden" });
+
+ await page.locator('.row.agent[data-id="grok"] .ag-handle').click();
+ await page.getByRole("menuitem", { name: w.sheet.replace("Codex", "Grok Build") }).click();
+ await sheet(page).waitFor();
+ assert.deepEqual(await shownIn(page, "#modal .editor.agent-prefs"), ["fullContextRow"], `${lang}: Grok Build's sheet`);
+ assert(await page.locator("#modal .dialog").evaluate((d) => d.scrollWidth <= d.clientWidth + 1), `${lang}: Grok Build's sheet fits 360`);
+ await page.keyboard.press("Escape");
+ await page.locator("#modal").waitFor({ state: "hidden" });
for (const id of CODEX) assert.equal(await page.locator(`#${id}`).count(), 1, `${lang}: ${id} back`);
assert.deepEqual(errors, []);
});
diff --git a/internal/gui/tests/compact-one-value.test.cjs b/internal/gui/tests/compact-one-value.test.cjs
index 03dc432e0..a133f5c75 100644
--- a/internal/gui/tests/compact-one-value.test.cjs
+++ b/internal/gui/tests/compact-one-value.test.cjs
@@ -80,11 +80,11 @@ function serve(lang, posts) {
}
const words = {
- en: { long: "Long conversations, shared by Codex and Claude Code", undo: "Undo" },
- zh: { long: "「长对话」,Codex 和 Claude Code 共用", undo: "撤销" },
- "zh-TW": { long: "「長對話」,Codex 與 Claude Code 共用", undo: "復原" },
- ja: { long: "「長い会話」。Codex と Claude Code で共通", undo: "取り消す" },
- de: { long: "„Lange Unterhaltungen“, die Codex und Claude Code teilen", undo: "Rückgängig" },
+ en: { long: "Long conversations, shared by Codex, Claude Code and Grok Build", undo: "Undo" },
+ zh: { long: "「长对话」,Codex、Claude Code 和 Grok Build 共用", undo: "撤销" },
+ "zh-TW": { long: "「長對話」,Codex、Claude Code 與 Grok Build 共用", undo: "復原" },
+ ja: { long: "「長い会話」。Codex、Claude Code、Grok Build で共通", undo: "取り消す" },
+ de: { long: "„Lange Unterhaltungen“, die Codex, Claude Code und Grok Build teilen", undo: "Rückgängig" },
};
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
diff --git a/internal/settings/settings.go b/internal/settings/settings.go
index 00e02e003..c51b161b9 100644
--- a/internal/settings/settings.go
+++ b/internal/settings/settings.go
@@ -566,7 +566,7 @@ type Settings struct {
// DesktopSubagentEffort fixes Desktop's subagent tool turns at this
// reasoning level. Empty keeps the effort each request asks for.
DesktopSubagentEffort string `json:"desktopSubagentEffort,omitempty"`
- // FullContext has Codex and Claude Code told a model's whole context
+ // FullContext has Codex, Claude Code and Grok Build told a model's whole context
// window. Off, a window above WorkingWindow is told as WorkingWindow,
// so they compact a long conversation there instead of sending ever
// more of it on every turn (X: Chen, a 1M DeepSeek model through