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.