Commit Graph
11 Commits
Author SHA1 Message Date
yetone 3eb2bda4f2 settings: Codex, Claude Code and Grok Build each take a Long conversations of their own (molianyin4227 on Discord)
molianyin4227 (Discord #help): models differ, so one compaction size
for every agent fits none; they asked for Codex, Claude Code and Grok
Build to each have their own, falling back to the shared one.

- settings.AgentCompacts[agent] {At, Full} for the agents that write a
  compaction window (CompactAgents: codex, claude, grok); Settings.
  ForAgent(agent) lays it over CompactAt/FullContext for that agent's
  readers only: codexcat.entriesAt, provider codexListed, Claude Code's
  writeCompact and desktopPlan, grokModelTables, the route list's
  buildModels, Codex's window line (api.go) and Tuned for you
  (gui/tune.go, agent/tune.go). A model's or provider's own Compact at
  still comes first. An agent with none follows the shared value, so
  nothing new is written for it, and an agent outside the three has no
  such key and is refused (provider.SetAgentCompact).
- POST /api/settings/agent-compact {agent, own, full, at}; own false
  takes the agent's value away. settingsapi.Merge keeps the map.
- GUI: a row "Long conversations in <agent>" under Long conversations,
  in the agent's opened row and its sheet: Every agent / Compact at N /
  Full window (segs, no select), a size box when Compact at. It lives in
  agentcompact.js, imported when the agent's settings hold Long
  conversations, then put in synchronously (an async put-in after a
  redraw moved the page in chromium: codex-memories-settings' scroll
  check). It draws again only when its own values change. i18n in
  zh, zh-TW, ja, de.
- Tuned for you's Use on an agent with its own value changes that one,
  stashed under tune.long.compact.<agent>; Undo puts it back.
- codex-memories-settings' "no Codex" check counts Long conversations
  alone again (:not(.agent-compact)) and waits for the new row.
- docs/subsystems/agent-wiring.md: a row for it.

Core size: app.js 1,311,919 bytes, 109 under origin/main 0ee424e3e
(1,312,028): the two calls are paid for by four comments cut. The core
total is 1,534,045, still over its budget as on main (#5139), 109 less
than main's 1,534,154. No budget raised.

Run at this tree (based on origin/main 0ee424e3e, fetched just before
the commit), all on mote via mote-run:
- go test settings, settingsapi, codexcat; provider/agent/gui with
  -run "Compact|Tune|Grok|SettingsSave|CodexWindow|Long": ok.
- New tests broken by hand, each red: ForAgent taken out of codexcat
  (TestCodexCatalogCompactAt), grok.go (TestGrokWindowFollowsLong
  Conversations), claude.go (TestClaudeCompactAt); tune's per-agent key
  turned off (TestTuneAgentOwnLong: "after apply: codex {At:0
  Full:true}"); the row's import call taken out of app.js
  (agent-compact.test.cjs 4 of 4 red in chromium).
- GUI, chromium + webkit (en/zh/zh-TW/ja/de as each file has, narrow
  and wide): agent-compact, agent-prefs, compact-at, compact-one-value,
  settings-general, codex-async-compact, codex-compact-held,
  codex-memories-settings, context-tune, segs-glide, i18n-keys,
  old-webkit: 432 of 432 ok.
- gofmt -l clean; go vet darwin and GOOS=windows on mote, linux with
  -tags gtk3 on magpie-desktop (wsl-run): ok.
- TestCoreScriptBudget: red, 1,534,045 > 1,533,802, as on main (#5139),
  109 bytes lower than main.

Not tried: real Codex, Claude Code or Grok Build reading the values
(the config writers are unit-tested); the full go test ./... (after
the push). `magpie model compact` has no per-agent flag, and t3code's
route list reads the shared value.
2026-11-04 16:17:47 +08:00
yetone c903c3a411 usage: Use on Codex's window lands over 7 and 30 days, a model's own Compact at named apart (hoobnn on Discord)
hoobnn on Discord (11-01): "观测-用量-上下文里,在7天或者30天的选项里,点击
应用codex的上下文,没生效。" Over 7 or 30 days the range held calls on a
model whose provider has a Compact at of its own (430K); today's didn't.
Tuned for you's "Now" was the largest compaction point over every model
in the range, so it came from that model. Use put the advice in Long
conversations, which did move Codex's other models (Codex's list had
them at the advice), but the card still read 430K and then turned held
("compacts at its own 430K, which comes first"), so nothing seemed to
happen. And with Long conversations at magpie's default, a range of
only such models offered a Use that could move nothing.

codexWindow (internal/gui/tune.go) now reads "Now" from the models Long
conversations moves, and lists each model with its own Compact at as
Apart (largest first). Only a range whose every model has its own is
held (Own), whatever Long conversations says. The card names each
model kept apart under the row: "{model} compacts at its own {value},
which this doesn't move", in en, zh, zh-TW, ja and de.
provider.CompactSetIn is CompactSet with the caller's settings and
group finder, as CompactFor takes them.

Siblings: Claude Code's knob is per model (no max over models), so it
has no such mix. 1, 7 and 30 days go through the same codexWindow;
the GUI test covers 7 and 30 and the Go test the 1-day sample.

Run on mote at d614f2172 plus this change, then at this head (on
7b6b7492a) again: TestCoreScriptBudget, TestTune*, context-tune and
i18n-keys, all ok.
- go test -tags nogui ./internal/provider ./internal/agent
  ./internal/codexcat: ok. ./internal/gui: ok but two tests red the same
  on a clean origin/main 9097687a3 (3 of 3 and 1 of 3), both filed:
  TestSettingsSaveKeepsWhatItDoesNotSend (BusyLoad, #4739) and
  TestColdTurnsTaken (#4510). TestTuneCodexUseLandsInEveryRange (new) puts
  two providers in a sandbox HOME, one with its own 430K, reads the
  advice for 1 model and for both, applies through agent.TuneApply as
  /api/tune/apply does, and checks the card and Codex's model list
  (codexcat): the other model at the advice, the own one at 430K.
- go vet (darwin), GOOS=linux go vet -tags nogui, GOOS=windows go vet
  for internal/gui and internal/provider; gofmt -l clean.
- node --test context-tune (178 pass, both engines, en/zh/zh-TW/ja/de,
  360 and 1100 wide), i18n-keys, gui-zh-tw, gui-de: pass. gui-ja: one
  red, "ja has every zh string", the #4532 string, filed as #4580 and
  fixed in its own commit next.
- TestCoreScriptBudget passes with no raise (two comments in
  context.js cut to fit: 1,533,023 of 1,533,105).

Broken by hand: with tune.go's Apart taken out, the new Go test is red
("only the model with its own 430K: own <nil>, now 430000" and "after
Use 120000: now 430000, own own/gpt-own-1m"); with the old context.js
the new GUI test is red, 42 of 42 (40 cases, both engines).

Not tried: hoobnn's own config on a real Codex; a profile-level
model_auto_compact_token_limit in config.toml (TuneRead reads the
top-level key as Locked, not a profile's); the whole Go suite and the
whole GUI suite (run after the push).
2026-11-01 15:19:32 +08:00
yetone 05f6ca39b3 provider, gui: settings only read go through the shared copy
settings.Load clones the whole Settings, every provider's model prefs
included. CompactsOf, OutputsOf, ModelNames, ModelEfforts,
settings.SavedAddr and the GUI's providerInfoWith only read it, and
providerInfoWith took a copy for each provider: 16 MB of what twenty
window polls allocated in a real-account sandbox, more with each
model a user has set prefs for.

They read settings.Shared() now. ModelEfforts hands back a clone of
the slice it finds, so a caller's change never reaches the shared
settings.

TestModelPrefsReadTheSharedSettings: 3000 other models' prefs; the
values are right, a caller's change to ModelEfforts' list doesn't
reach the settings, and each look allocates at most a tenth of
Load's. Red on the old code: ~6058 allocations a look against 6056
for a Load.

Run at this head on mote: go vet (darwin, GOOS=windows, GOOS=linux
without the gui package) ok; go test ./internal/settings and
./internal/provider ok; ./internal/gui red only in
TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestMainWindowCorners (#3949), both red on main.
2026-11-01 04:05:38 +08:00
yetone f985d6bdb6 provider: a Max output kept for a model no longer listed doesn't block the editor's Save (#3305, LoKi)
LoKi (#3305, Windows, v0.1.1325, Zen Free plugin 0.1.14): settings.json
held "opencode-zen-free/space-bunny-free": 65536 from when Zen Free
listed it. OutputsOf gives the editor every saved limit, the editor
sends them back as `outputs` on every Save, and SetModelOutputs refused
any positive entry for a model the provider doesn't serve, so each Save
failed with "opencode-zen-free has no model space-bunny-free", with no
model picked too.

SetModelOutputs (models.go) and its sibling SetModelCompacts
(compact.go, the editor's Compact at, same check and same round trip)
now refuse an unserved model only when its value is new or changed: an
entry sent back as it is stored is kept, and the rest of the Save goes
through. The user's value isn't deleted, since they set it and the model
may come back on the next refresh. It still shows in Max output as
model=size, and taking it out there clears it, as before. A newly typed
model the provider doesn't serve, or a changed value for a retired one,
is refused as before. SetModelOutput (the CLI's single set) is unchanged.

Siblings checked: the editor's Context window goes through provider.Save,
which never checks it against the list, so a retired model's window
already saved; Names & levels (modelPrefs) sends only the entries
changed in that editor session (modelPrefsOfDraft), so a retired one
isn't resent.

Run at 45593cc1d (origin/main, unchanged at push) plus this change:
- TestRetiredModelLimitsDontBlockTheEditor (provider; outputs and
  compacts) and TestProviderSaveKeepsRetiredModelOutput (gui, through
  /api/provider/save: the model leaves the list, Select none, a stale
  limit beside a new one, a newly typed "typo" refused, cleared): ok.
- Broken by hand (the `!= n` term dropped from both setters): both red,
  "relay has no model luna" (each subtest) and 400 "relay has no model
  space-bunny-free".
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: ok.
- go test -tags nogui -timeout 45m ./... (darwin, one suite on the
  machine): every package ok (agent 442s, gateway 794s, gui 178s,
  provider 218s), no FAIL in the log.
Not tried: the reporter's Windows machine or the real Zen Free plugin
(the fix is in a provider-kind-independent settings comparison); no GUI
change, so no Playwright run.
2026-10-23 03:35:27 +08:00
yetone 81a24cf8fe groups: a found group is listed as auto/<model id as the vendor spells it>
ZeroClover asked on X: Auto Group ids group/auto-<slug> can't be looked
up on models.dev. A found group is now listed and written as
auto/<model>, e.g. auto/claude-opus-5.5: /v1/models, the catalog, agent
configs, the GUI's Routing page and the CLI. Context and output limits
come from the model's metadata as before.

What stays the same:
- The internal id is still group/auto-<slug> (Group.Ref() gives the
  public one). Every old form is still accepted as input forever:
  provider.CanonicalRef turns auto/<model>[:level][[1m]] into it at the
  gateway (validateModel), keys, stats, affinity and usage, so both ids
  route to the same group and count as one.
- A key's model list allows a model by either id, group/* included
  (allows() in key_models.go).
- Hand-made groups stay group/<id>.
- A provider whose stored id is "auto" keeps its models: while one
  exists, found groups are listed by their old id (AutoRefsOn) and
  auto/<x> means that provider's model. Documented in
  docs/subsystems/gateway-routing.md.

Agent configs: SyncCatalog rewrites a field that holds a found group's
old id (renameFoundGroups), but only while the value is still what
applied.json says magpie wrote; a value the user set stays. A pick by
the old id written now is written as auto/<model> (Apply). Hidden,
picked and ordered model lists saved by the old id hold for the new one
(visible.go), and a bare model id still reaches its found group (bare.go).

Claude Code is given a dotted Claude version dashed (ClaudeSpelled), so
auto/claude-sonnet-4.5 sits in its settings as auto/claude-sonnet-4-5.
That routes to the same group, but with found groups off nothing reads
it back dotted, and Reseat took the field for changed and left the agent
on a group that was gone. Reseat now compares a group pick by its
canonical id (samePick). The old ids had no dots, so this is new with
auto/<model>.

Run at this tree (sandbox HOME, caches pinned):
- gofmt -l: clean. go vet ./...: clean on darwin, GOOS=linux -tags
  nogui, GOOS=windows.
- go test -p 4 -timeout 45m ./...: every package ok except agent and
  gateway, whose failures were the tests' expected ids (updated here)
  and two regressions now fixed (bare ids; desktop models hiding groups
  by prefix). Every failing test passes on rerun. Load average was
  ~210-290 from other sessions throughout.
- Reruns: provider, cli, codexcat ok. internal/gui: only
  TestSetAnswersWhileDevinAndProvidersHang fails (set slow/slow-1 took
  10.19s), and it fails the same in a git-archive export of 33dbdcc52.
- agent and gateway in full, -p 2 -timeout 120m: gateway ok (2996s).
  agent failed four tests that still expected the old ids
  (TestOmp/PiModelsAskedOnTheirNativeAPI, TestReseatFoundGroupsOff,
  TestReseatKeepsAFoundGroupWithAProviderOff); updating them showed the
  Reseat bug above. After the fix, go test -count=1 -timeout 120m
  ./internal/agent/: ok (1000s, load ~160-220).
- GUI files the change reaches, chromium and webkit: group-found-off and
  the routing files pass, except routing-bodies, routing-model-rest,
  routing-keys-fold and routing-request-metrics, which fail the same with
  33dbdcc52's JS.

Broken by hand and watched red, then restored: CanonicalRef in
validateModel (both-ids routing test), allows() (key tests both ways),
the Save refusal and AutoRefsOn checks in Ref/CanonicalRef (provider
named auto), catalog.Lists' preference (models.dev lookup of the part
after auto/), renameFoundGroups' applied.json check and its SyncCatalog
call (user values kept), PublicRef in visible.go, the codexcat prefix,
samePick in Reseat (TestReseatFoundGroupsOff: opus left on the gone
group).
TestBareModelIDsShared was red before the bare.go fix.

Not verified: no real agent, vendor or models.dev client run; no run on
the Windows box. Settings pickers (vision, title model) holding a saved
group/auto-... value may show it as saved. codexcat can't tell a stored
"auto" provider apart, so its models lose the "text only" hint. The
pre-existing reds above are not filed.
2026-10-20 00:18:51 +08:00
yetone be6a74f13e provider: a routing group told its largest member's window runs to it when the user typed it (Osal on Discord)
Osal set the codex provider's windows to each model's most (gpt-6-astra=872k
and the rest) and ran Codex on "6 Astra · routing group Ultra". Codex said
"已用 114k 标记,共 258k": 95% of magpie's default working window, 272K.

A group that names no size of its own is told its largest member's window
(#712), but buildGroupEntries never carried whether the user typed that
window (Entry.WindowSet), as it does for a group set to a size (#1809) or
one following its smallest member (#2224). CompactFor then returned 0 and
codexcat wrote context_window 272000, max_context_window 872000. Now the
largest member's WindowSet comes along (a tie counts as typed), unless a
rule of length lifted the window past it; WindowTyped says the same for
Claude Code and Claude Desktop (largestWindow). A group whose largest
member's window nobody typed keeps the default, and a size typed in
Settings (Compact at) still comes first.

TestLargestMemberTypedWindow (internal/agent): on the old code the
gateway's list compacts group/ultra at 0, magpie-models.json tells it
272000 (max 872000), Claude Code gets CLAUDE_CODE_AUTO_COMPACT_WINDOW
272000 and Claude Desktop no per-model window; all four pass now, and a
group whose 1M member is untyped keeps 272K.

Run: gofmt -l (clean); go vet ./... on darwin, GOOS=linux -tags nogui,
GOOS=windows (clean); go test -run 'TestLargestMemberTypedWindow|
TestSmallestMemberTypedWindow|TestTypedWindowReaches' ./internal/agent;
go test -timeout 45m ./... at eb3f17428 + this change (load ~260-290):
every package ok but agent, gateway and library, which timed out at 45m
while still running ordinary tests (TestClaudeTierPickedAsTheMainModelStays,
TestPayloadTooLargeTriesAnotherMember, TestRemoveSkillLeavesProjects);
rerun with -timeout 120m (load ~400): agent ok (5048s), gateway ok
(4138s), library red only in TestCheckStdio/timeout_ends_the_tree
("pids [one]: the server and its child should both have started"),
the load red already filed as #2765. After rebasing on dd70c5e6a:
go build ./..., go test ./internal/provider and the agent window tests
(-run 'TypedWindow|Window') rerun.
Not tried with Osal's real ChatGPT account or a live Codex; no GUI change.
2026-10-19 21:55:33 +08:00
yetone 8f4d091c6e provider: a group following its smallest member runs to that member's window when the user typed it, not magpie's 272K (#2224, Zypixh)
A group set to "smallest member" was told the smallest window, but not
that it was one the user typed: groupEntries set Entry.WindowSet only
for a group's own size, and WindowTyped said yes only for g.Context > 0.
So a 500K typed on the provider for gpt-6.1-sol reached /v1/models, yet
Claude Desktop's modelSettings.<id>.autoCompactWindow and Codex's
compaction were magpie's default 272K, while the same group set to 500K
itself got 500K.

smallestWindow now gives the smallest window among a group's members and
whether the member it comes from has a typed one (a tie counts as typed);
groupEntries carries that into WindowSet (Codex, CompactFor) and
WindowTyped asks it for a smallest-member group (Claude Code and Desktop).
Members are already flattened through groups in groups, so an outer
group passes it on. A group whose smallest member's window nobody typed,
and largest/unset groups, are unchanged.

Run (sandbox HOME, pinned caches):
- TestSmallestMemberTypedWindow (new, internal/agent): on the old code
  FAIL "the gateway's list compacts group/pool at 0; want 500000" and
  "Claude Desktop: group/pool ... compacts at "272000"; want "500000"",
  same for the nested group/outer; with only compact.go reverted the
  Desktop lines fail. With the fix ok; group/plain (untyped) stays 272000.
- go test -count=1 -timeout 30m ./internal/provider/ ./internal/agent/
  ./internal/gateway/: ok (374s, 958s, 1042s on a loaded machine; a
  first run with the default 10m timeout timed out in gateway under load)
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean.
Not run: the full go test ./... (disk kept low); not tried with the real
Claude Desktop.
2026-10-15 01:24:14 +08:00
yetone f94809d23e agent: Claude Code isn't handed 272000 for a routing group made only of Claude models (#1741, yanjieee)
writeCompact gives a Claude model its own window (no
CLAUDE_CODE_AUTO_COMPACT_WINDOW unless the user set a threshold), but
claudeModel looks only at the id's last part, so group/auto-claude-opus-5-5
or any group of Claude [1m] models was told magpie's default 272000.
provider.ClaudeGroup is true when every member of a group (nested groups
flattened, by the listed name or the wire name, Bedrock names included)
is a Claude model; writeCompact now treats such a group as it treats a
Claude model. A group with another vendor's model keeps 272000. A
threshold set on a member's provider still comes first (CompactSet), and
the user's own env, autoCompactWindow and modelSettings are untouched.

Siblings: only Claude Code has a Claude exemption. Codex (codexcat
work.Working, route.go/models.go CompactFor) applies the working window
to every model, so has no group misread. claudeOutput's claudeModel uses
are about output tokens and are left as they are. Part (b), per-model
modelSettings windows, is tracked separately.

Run: TestClaudeGroupCompactWindow (new) fails on the old writeCompact
("a group of Claude models: 272000"), passes now, with a user-owned env
500000 and autoCompactWindow 900000 kept; go test ./internal/agent
./internal/provider; gofmt -l; go vet darwin, linux -tags nogui, windows.
Not tried in a real Claude Code session.
2026-10-13 05:21:04 +08:00
yetone f340aecabc provider, agent: a context window the user typed on a routing group or a provider is the one Codex and Claude Code run to, not magpie's default 272K (#1809)
A DeepSeek V4.1 Flash routing group set to 500K reached the catalog as
Context 500000, but magpie's default working window (settings.Working,
272K, #876) cut it: Codex's magpie-models.json said context_window
272000, max_context_window 500000, and Codex runs to 95% of
context_window, the ~258K in the report. Claude Code showed 500K
(CLAUDE_CODE_MAX_CONTEXT_TOKENS) while magpie also wrote
CLAUDE_CODE_AUTO_COMPACT_WINDOW=272000, so it compacted at 272K too and
only displayed the larger number.

From Codex's source (openai/codex @0c7362d, codex-cli 0.162.1):
config.toml's model_context_window sets context_window to
min(value, max_context_window); usable = context_window x
effective_context_window_percent (95 by default); the auto-compact
limit is min(model_auto_compact_token_limit, 90% of context_window).
magpie writes neither config key and still doesn't, so a user's own
model_context_window keeps working as before.

magpie's default compaction now gives way to a window the user typed,
as it already gives way to Claude Code's own autoCompactWindow
(602d4ec6):
- provider: Entry.WindowSet marks a window typed on the provider for
  the model or all its models (ContextOf) or on the group (a size).
  CompactFor answers the threshold Codex is told: a per-model or
  provider Compact at first (CompactSet), else that whole typed window
  when no size is typed in Settings, else 0 (the default). Used by the
  gateway's Codex list (codexListed) and WindowTyped for Claude Code.
- agent: magpie-models.json (and the WSL twin) take CompactFor, so the
  group says context_window 500000 with no max; Claude Code gets no
  AUTO_COMPACT_WINDOW on a typed window unless Compact at is typed in
  Settings.
- A model nobody typed a window for keeps 272K, and a Compact at size
  typed in Settings still comes before a typed window.
- gui: unchanged. f36e744c3 shortened Settings > Long conversations to
  one line upstream; it no longer spells out precedence.

Run:
- internal/agent TestTypedWindowReachesCodexAndClaudeCode: group 500K,
  provider per-model 400K, an untyped 1M model, then Compact at 300K;
  checks magpie-models.json, the gateway's Codex list and Claude Code's
  env. On the old code it fails 6 ways (272000/500000 and 272000/400000
  on disk, list Compact 0, Claude compact 272000), checked by reverting
  the non-test files.
- Sandbox HOME with the built binary and real codex 0.162.1
  (`codex debug models`): old binary group/ds-flash 272000 / max
  500000; new 500000, no max. A per-model `context` override of 1m:
  old 272000 / 1000000, new 1000000. `magpie model compact 300k`:
  300000 with the typed window as max. Claude Code in the sandbox: old
  wrote AUTO_COMPACT_WINDOW=272000 + MAX_CONTEXT_TOKENS=500000, new
  only MAX_CONTEXT_TOKENS=500000.
- gofmt -l, go vet (darwin, GOOS=linux -tags nogui, GOOS=windows), the
  three builds, go test -tags nogui ./...: 45 packages ok. At load
  average ~115 agent, gateway, library and provider hit the 10m
  timeout with no failure. Rerun with -timeout 40m, agent, library and
  provider pass. gateway failed three timing tests that pass 3 of 3
  alone: TestOTelWaterfallIncludesUnbilledFallback (#1794, already
  fixed on origin/main by 6ae6b3402), TestCodexHeardWithinItsIdleTimeout
  (#1800, open) and TestIntentClassifierFails (filed as #1829).

Not tried: a real `codex exec` turn against a sandbox gateway (the
catalog Codex reads was checked with `codex debug models` instead), and
Windows itself; the path is the same Go code on every OS.
2026-10-12 23:22:33 +08:00
TryWorldandTryWorld2026 116ca957cc agent: a provider's Compact at reaches Codex's on-disk catalog (#876) (#924)
Where Codex compacts a long conversation reached the gateway's /models
(provider.CodexListed sets catalog.Model.Compact) and Claude Code
(claude.go calls provider.CompactSet), but not the list magpie writes for
Codex on disk: magpieModels left Compact unset, so codexcat fell back to
the threshold for every model. A threshold the user set on a model or on
its provider did nothing while Codex read that list — the case where Codex
is not signed in to ChatGPT and model_catalog_json is what it reads.

magpieModels now carries it, as the gateway's list and Claude Code already
do. provider.CompactSetIn is compactSet for a caller holding the settings
and the group finder already, as EffectivePriceIn is for prices: this loop
runs for hundreds of models at magpie's start.

TestCodexCatalogCompactAtReachesDisk fails without the change (204800, want
100000) and passes with it: relay's "*" and then relay/glm-4.6's own
threshold reach the file, with the model's window kept as the maximum, and
the whole window comes back when they are cleared.

Co-authored-by: TryWorld2026 <tryworld@users.noreply.github.com>
2026-10-05 23:45:52 +08:00
yetone 1aaac93b52 provider, gui: Compact at — where Codex and Claude Code compact a long conversation, set per provider or per model in its editor and to any size in Settings → Long conversations (#876, hisiling)
Until now the only choice was 272K for every model or Full window for every model. The 272K default stays as it is (e950eb08: OpenAI runs its own 1M models at 272K in Codex, and Chen saw 70–90s to a first token at 550K).

What changes:

- A provider's editor has Compact at beside Context window and Max output, in the same form: "500k" for all of its models, "deepseek-v4-flash=272k" for one, and empty to follow Settings. A size at or above a model's window means the whole window. The values are kept in settings.ModelCompacts.
- Settings → Long conversations takes a size of its own beside Compact at / Full window (settings.CompactAt).
- `magpie model compact` takes a size such as 500k.

Order: the model's own value, then its provider's "*", then Settings. Full window turns off only the Settings value. A group uses the smallest value among its members.

Where it applies:

- Codex's model_catalog is told the threshold as context_window, with the whole window as max_context_window.
- Claude Code's CLAUDE_CODE_AUTO_COMPACT_WINDOW follows the main model. A Claude model now takes its provider's value when one is set.
- The Codex list tag changes when the Settings size or Full window changes.

Tests:

- New: TestModelCompactsSetFromTheEditor, TestSetCompactAt, TestCodexCatalogCompactAt and TestClaudeCompactAt.
- TestSettingsSaveKeepsWhatItDoesNotSend now covers the two new fields.
- compact-at.test.cjs (WebKit, en/zh) checks the editor field (shown, refused, chips, saved) and the Settings size (posted, hidden under Full window, no scroll).
- go vet ./..., go test -tags nogui of the root package, provider, codexcat, agent, gui, gateway, settings and catalog under a temp HOME, and GOOS=linux/windows builds all pass.
2026-10-05 15:20:05 +08:00