Skip to content

Commit 615d767

Browse files
committed
checkpoint: 2025/09/02 13:06:45
1 parent 39cad2e commit 615d767

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

internal/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ func (ai *AIConfig) Validate() error {
260260
return fmt.Errorf("temperature must be between 0 and 2, got %f", ai.Temperature)
261261
}
262262

263-
if ai.MaxTokens <= 0 {
264-
return fmt.Errorf("max_tokens must be positive, got %d", ai.MaxTokens)
263+
if ai.MaxTokens < 0 {
264+
return fmt.Errorf("max_tokens must be non-negative, got %d", ai.MaxTokens)
265265
}
266266

267267
// Provider-specific validation

internal/config/config_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TestNewDefaultConfig(t *testing.T) {
3535
assert.Equal(t, "openai", cfg.AI.Provider)
3636
assert.Equal(t, "o3", cfg.AI.Model)
3737
assert.Equal(t, float32(0.7), cfg.AI.Temperature)
38-
assert.Equal(t, 4096, cfg.AI.MaxTokens)
38+
assert.Equal(t, 0, cfg.AI.MaxTokens)
3939
assert.Equal(t, "info", cfg.Logging.Level)
4040
assert.Equal(t, "text", cfg.Logging.Format)
4141
assert.True(t, cfg.Logging.Timestamp)
@@ -139,14 +139,23 @@ func TestConfigValidate(t *testing.T) {
139139
assert.Contains(t, err.Error(), "temperature must be between 0 and 2")
140140
})
141141

142-
t.Run("invalid max tokens", func(t *testing.T) {
142+
t.Run("valid max tokens zero", func(t *testing.T) {
143143
cfg := NewDefaultConfig()
144144
cfg.AI.APIKey = "test-key"
145145
cfg.AI.MaxTokens = 0
146146

147+
err := cfg.Validate()
148+
assert.NoError(t, err)
149+
})
150+
151+
t.Run("invalid max tokens negative", func(t *testing.T) {
152+
cfg := NewDefaultConfig()
153+
cfg.AI.APIKey = "test-key"
154+
cfg.AI.MaxTokens = -100
155+
147156
err := cfg.Validate()
148157
assert.Error(t, err)
149-
assert.Contains(t, err.Error(), "max_tokens must be positive")
158+
assert.Contains(t, err.Error(), "max_tokens must be non-negative")
150159
})
151160

152161
t.Run("azure missing endpoint", func(t *testing.T) {

0 commit comments

Comments
 (0)