mirror of
https://github.com/ollama/ollama.git
synced 2026-10-21 02:51:35 +00:00
respect CLAUDE_CODE_AUTO_COMPACT_WINDOW user setting
This commit is contained in:
parent
c77b81c503
commit
0c7340b4bb
2 changed files with 17 additions and 4 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue