diff --git a/internal/domain/thinking.go b/internal/domain/thinking.go index deab8b13..45c930bb 100644 --- a/internal/domain/thinking.go +++ b/internal/domain/thinking.go @@ -10,9 +10,25 @@ const ( ThinkingHigh ThinkingLevel = "high" ) +// ThinkingBudgets defines standardized token budgets for reasoning-enabled models. +// The map assigns a maximum token count to each ThinkingLevel, representing the +// amount of context or computation that can be used for reasoning at that level. +// These values (e.g., 1024 for low, 2048 for medium, 4096 for high) are used to +// Token budget constants for each ThinkingLevel. +// These values are chosen to align with typical context window sizes for LLMs at different reasoning levels. +// Adjust these if model capabilities change. +const ( + // TokenBudgetLow is suitable for basic reasoning or smaller models (e.g., 1k context window). + TokenBudgetLow int64 = 1024 + // TokenBudgetMedium is suitable for intermediate reasoning or mid-sized models (e.g., 2k context window). + TokenBudgetMedium int64 = 2048 + // TokenBudgetHigh is suitable for advanced reasoning or large models (e.g., 4k context window). + TokenBudgetHigh int64 = 4096 +) + // ThinkingBudgets defines standardized token budgets for reasoning-enabled models. var ThinkingBudgets = map[ThinkingLevel]int64{ - ThinkingLow: 1024, - ThinkingMedium: 2048, - ThinkingHigh: 4096, + ThinkingLow: TokenBudgetLow, + ThinkingMedium: TokenBudgetMedium, + ThinkingHigh: TokenBudgetHigh, } diff --git a/internal/plugins/ai/anthropic/anthropic.go b/internal/plugins/ai/anthropic/anthropic.go index a29637b2..cff29ad9 100644 --- a/internal/plugins/ai/anthropic/anthropic.go +++ b/internal/plugins/ai/anthropic/anthropic.go @@ -167,7 +167,9 @@ func parseThinking(level domain.ThinkingLevel) (anthropic.ThinkingConfigParamUni } default: if tokens, err := strconv.ParseInt(lower, 10, 64); err == nil { - return anthropic.ThinkingConfigParamOfEnabled(tokens), true + if tokens >= 1 && tokens <= 10000 { + return anthropic.ThinkingConfigParamOfEnabled(tokens), true + } } } return anthropic.ThinkingConfigParamUnion{}, false