Skip to content

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

respect CLAUDE_CODE_AUTO_COMPACT_WINDOW user setting

Jonathan Berg0c7340b4bb3d
diff --git a/cmd/launch/claude.go b/cmd/launch/claude.go
index 6fd116def..ca96991b8 100644
--- a/cmd/launch/claude.go
+++ b/cmd/launch/claude.go
@@ -179,10 +179,10 @@ 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,
- "CLAUDE_CODE_AUTO_COMPACT_WINDOW="+window,
- )
+ 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)
+ }
}
}
diff --git a/cmd/launch/claude_test.go b/cmd/launch/claude_test.go
index 4bfeeba93..e89bc08ab 100644
--- a/cmd/launch/claude_test.go
+++ b/cmd/launch/claude_test.go
@@ -431,6 +431,7 @@ func TestClaudeModelEnvVars(t *testing.T) {
c := &Claude{}
windowKeys := []string{"CLAUDE_CODE_MAX_CONTEXT_TOKENS", "CLAUDE_CODE_AUTO_COMPACT_WINDOW"}
+ t.Setenv("CLAUDE_CODE_AUTO_COMPACT_WINDOW", "")
envMap := func(envs []string) map[string]string {
m := make(map[string]string)
@@ -497,6 +498,18 @@ func TestClaudeModelEnvVars(t *testing.T) {
}
})
+ 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")
+ got := envMap(c.modelEnvVars("kimi-k2.6:cloud"))
+ if v, ok := got["CLAUDE_CODE_AUTO_COMPACT_WINDOW"]; ok {
+ t.Errorf("AUTO_COMPACT_WINDOW = %q, want left to the user's setting", v)
+ }
+ if got["CLAUDE_CODE_MAX_CONTEXT_TOKENS"] != "262144" {
+ t.Errorf("MAX_CONTEXT_TOKENS = %q, want 262144", got["CLAUDE_CODE_MAX_CONTEXT_TOKENS"])
+ }
+ })
+
t.Run("does not set windows for unknown cloud models", func(t *testing.T) {
got := envMap(c.modelEnvVars("unknown-model:cloud"))
for _, key := range windowKeys {