@@ -70,21 +70,27 @@ func (c *Client) createBetaStream(
7070 params .OutputFormat = anthropic .BetaJSONSchemaOutputFormat (structuredOutput .Schema )
7171 }
7272
73+ // Configure thinking if not explicitly disabled via /think command
7374 // For interleaved thinking to make sense, we use a default of 16384 tokens for the thinking budget
74- thinkingTokens := int64 (16384 )
75- if c .ModelConfig .ThinkingBudget != nil {
76- thinkingTokens = int64 (c .ModelConfig .ThinkingBudget .Tokens )
75+ thinkingEnabled := c .ModelOptions .Thinking () == nil || * c .ModelOptions .Thinking ()
76+ if thinkingEnabled {
77+ thinkingTokens := int64 (16384 )
78+ if c .ModelConfig .ThinkingBudget != nil {
79+ thinkingTokens = int64 (c .ModelConfig .ThinkingBudget .Tokens )
80+ } else {
81+ slog .Info ("Anthropic Beta API using default thinking_budget with interleaved thinking" , "budget_tokens" , thinkingTokens )
82+ }
83+ switch {
84+ case thinkingTokens >= 1024 && thinkingTokens < maxTokens :
85+ params .Thinking = anthropic .BetaThinkingConfigParamOfEnabled (thinkingTokens )
86+ slog .Debug ("Anthropic Beta API using thinking_budget with interleaved thinking" , "budget_tokens" , thinkingTokens )
87+ case thinkingTokens >= maxTokens :
88+ slog .Warn ("Anthropic Beta API thinking_budget must be less than max_tokens, ignoring" , "tokens" , thinkingTokens , "max_tokens" , maxTokens )
89+ default :
90+ slog .Warn ("Anthropic Beta API thinking_budget below minimum (1024), ignoring" , "tokens" , thinkingTokens )
91+ }
7792 } else {
78- slog .Info ("Anthropic Beta API using default thinking_budget with interleaved thinking" , "budget_tokens" , thinkingTokens )
79- }
80- switch {
81- case thinkingTokens >= 1024 && thinkingTokens < maxTokens :
82- params .Thinking = anthropic .BetaThinkingConfigParamOfEnabled (thinkingTokens )
83- slog .Debug ("Anthropic Beta API using thinking_budget with interleaved thinking" , "budget_tokens" , thinkingTokens )
84- case thinkingTokens >= maxTokens :
85- slog .Warn ("Anthropic Beta API thinking_budget must be less than max_tokens, ignoring" , "tokens" , thinkingTokens , "max_tokens" , maxTokens )
86- default :
87- slog .Warn ("Anthropic Beta API thinking_budget below minimum (1024), ignoring" , "tokens" , thinkingTokens )
93+ slog .Debug ("Anthropic Beta API: Thinking disabled via /think command" )
8894 }
8995
9096 if len (requestTools ) > 0 {
0 commit comments