Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
Set CLAUDE_CODE_MAX_CONTEXT_TOKENS to whatever the models context window is
Jonathan Bergc77b81c5036b
diff --git a/cmd/launch/claude.go b/cmd/launch/claude.goindex 1a9700b9e..6fd116def 100644--- a/cmd/launch/claude.go+++ b/cmd/launch/claude.go@@ -178,7 +178,11 @@ func (c *Claude) modelEnvVars(model string) []string {if isCloudModelName(model) {if l, ok := lookupCloudModelLimit(model); ok {- env = append(env, "CLAUDE_CODE_AUTO_COMPACT_WINDOW="+strconv.Itoa(l.Context))+ window := strconv.Itoa(l.Context)+ env = append(env,+ "CLAUDE_CODE_MAX_CONTEXT_TOKENS="+window,+ "CLAUDE_CODE_AUTO_COMPACT_WINDOW="+window,+ )}}diff --git a/cmd/launch/claude_test.go b/cmd/launch/claude_test.goindex 2c688ead6..4bfeeba93 100644--- a/cmd/launch/claude_test.go+++ b/cmd/launch/claude_test.go@@ -430,6 +430,8 @@ printf '%s\n' "${CLAUDE_CODE_AUTO_MODE_SERVER-unset}" "$ANTHROPIC_DEFAULT_SONNETfunc TestClaudeModelEnvVars(t *testing.T) {c := &Claude{}+ windowKeys := []string{"CLAUDE_CODE_MAX_CONTEXT_TOKENS", "CLAUDE_CODE_AUTO_COMPACT_WINDOW"}+envMap := func(envs []string) map[string]string {m := make(map[string]string)for _, e := range envs {@@ -453,8 +455,10 @@ func TestClaudeModelEnvVars(t *testing.T) {if got["CLAUDE_CODE_SUBAGENT_MODEL"] != "llama3.2" {t.Errorf("SUBAGENT = %q, want llama3.2", got["CLAUDE_CODE_SUBAGENT_MODEL"])}- if got["CLAUDE_CODE_AUTO_COMPACT_WINDOW"] != "" {- t.Errorf("AUTO_COMPACT_WINDOW = %q, want empty for local models", got["CLAUDE_CODE_AUTO_COMPACT_WINDOW"])+ for _, key := range windowKeys {+ if v, ok := got[key]; ok {+ t.Errorf("%s = %q, want unset for local models", key, v)+ }}})@@ -472,22 +476,33 @@ func TestClaudeModelEnvVars(t *testing.T) {if got["CLAUDE_CODE_SUBAGENT_MODEL"] != "" {t.Errorf("SUBAGENT = %q, want empty", got["CLAUDE_CODE_SUBAGENT_MODEL"])}- if got["CLAUDE_CODE_AUTO_COMPACT_WINDOW"] != "" {- t.Errorf("AUTO_COMPACT_WINDOW = %q, want empty", got["CLAUDE_CODE_AUTO_COMPACT_WINDOW"])+ for _, key := range windowKeys {+ if v, ok := got[key]; ok {+ t.Errorf("%s = %q, want unset", key, v)+ }}})- t.Run("sets auto compact window for known cloud models", func(t *testing.T) {- got := envMap(c.modelEnvVars("glm-5:cloud"))- if got["CLAUDE_CODE_AUTO_COMPACT_WINDOW"] != "202752" {- t.Errorf("AUTO_COMPACT_WINDOW = %q, want 202752", got["CLAUDE_CODE_AUTO_COMPACT_WINDOW"])+ t.Run("sets context and auto compact windows for known cloud models", func(t *testing.T) {+ for model, want := range map[string]string{+ "glm-5:cloud": "202752",+ "kimi-k2.6:cloud": "262144",+ } {+ got := envMap(c.modelEnvVars(model))+ for _, key := range windowKeys {+ if got[key] != want {+ t.Errorf("%s: %s = %q, want %s", model, key, got[key], want)+ }+ }}})- t.Run("does not set auto compact window for unknown cloud models", func(t *testing.T) {+ t.Run("does not set windows for unknown cloud models", func(t *testing.T) {got := envMap(c.modelEnvVars("unknown-model:cloud"))- if got["CLAUDE_CODE_AUTO_COMPACT_WINDOW"] != "" {- t.Errorf("AUTO_COMPACT_WINDOW = %q, want empty", got["CLAUDE_CODE_AUTO_COMPACT_WINDOW"])+ for _, key := range windowKeys {+ if v, ok := got[key]; ok {+ t.Errorf("%s = %q, want unset", key, v)+ }}})}