Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

avoid scary claude warning about auto compact window being too big

Jonathan Bergb5c4e9058a9a
diff --git a/cmd/launch/claude.go b/cmd/launch/claude.go
index 73aa1c749..68c1db796 100644
--- a/cmd/launch/claude.go
+++ b/cmd/launch/claude.go
@@ -168,6 +168,14 @@ func claudeInstallerCommand(goos string) (string, []string, error) {
}
}
+// As of 2026-10-19 (cc version 2.1.304), claude code warns the following:
+// CLAUDE_CODE_AUTO_COMPACT_WINDOW="1048576" is too large, so Claude Code treats it as the 1M maximum.
+// Set it to a size from 100k to 1M, such as 200k or 200000, or unset it.
+const (
+ claudeMinAutoCompactWindow = 100_000
+ claudeMaxAutoCompactWindow = 1_000_000
+)
+
// modelEnvVars returns Claude Code env vars that route all model tiers through Ollama.
func (c *Claude) modelEnvVars(model string) []string {
env := []string{
@@ -179,10 +187,9 @@ func (c *Claude) modelEnvVars(model string) []string {
if isCloudModelName(model) {
if l, ok := lookupCloudModelLimit(model); ok {
- window := strconv.Itoa(l.Context)
- env = append(env, "CLAUDE_CODE_MAX_CONTEXT_TOKENS="+window)
- if os.Getenv("CLAUDE_CODE_AUTO_COMPACT_WINDOW") == "" {
- env = append(env, "CLAUDE_CODE_AUTO_COMPACT_WINDOW="+window)
+ env = append(env, "CLAUDE_CODE_MAX_CONTEXT_TOKENS="+strconv.Itoa(l.Context))
+ if os.Getenv("CLAUDE_CODE_AUTO_COMPACT_WINDOW") == "" && l.Context >= claudeMinAutoCompactWindow {
+ env = append(env, "CLAUDE_CODE_AUTO_COMPACT_WINDOW="+strconv.Itoa(min(l.Context, claudeMaxAutoCompactWindow)))
}
}
}
diff --git a/cmd/launch/claude_test.go b/cmd/launch/claude_test.go
index cc3ea7998..edeb4a6fc 100644
--- a/cmd/launch/claude_test.go
+++ b/cmd/launch/claude_test.go
@@ -541,6 +541,19 @@ func TestClaudeModelEnvVars(t *testing.T) {
}
})
+ t.Run("keeps the auto compact window within Claude Code's range", func(t *testing.T) {
+ setDynamicCloudModelLimits(map[string]cloudModelLimit{"tiny": {Context: 65_536}})
+ t.Cleanup(func() { setDynamicCloudModelLimits(nil) })
+ for model, want := range map[string]string{
+ "nemotron-3-nano:30b:cloud": "1000000",
+ "tiny:cloud": "",
+ } {
+ if got := envMap(c.modelEnvVars(model))["CLAUDE_CODE_AUTO_COMPACT_WINDOW"]; got != want {
+ t.Errorf("%s: AUTO_COMPACT_WINDOW = %q, want %q", model, got, want)
+ }
+ }
+ })
+
t.Run("keeps the user's auto compact window but not their context window", func(t *testing.T) {
t.Setenv("CLAUDE_CODE_AUTO_COMPACT_WINDOW", "150000")
t.Setenv("CLAUDE_CODE_MAX_CONTEXT_TOKENS", "150000")