github.com/anthropics/anthropic-sdk-go@v1.70.1/thinking_warn.go (about)

     1  package anthropic
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  )
     7  
     8  // modelsToWarnWithThinkingEnabled lists models for which `thinking.type=enabled`
     9  // (i.e. budget_tokens-based extended thinking) is deprecated in favor of
    10  // `thinking.type=adaptive`.
    11  var modelsToWarnWithThinkingEnabled = map[string]bool{
    12  	"claude-opus-4-6":       true,
    13  	"claude-mythos-preview": true,
    14  }
    15  
    16  // warnIfThinkingEnabled prints a deprecation warning to stderr when a request
    17  // uses `thinking.type=enabled` with a model that supports adaptive thinking.
    18  // This matches the runtime warning emitted by the other Anthropic SDKs.
    19  func warnIfThinkingEnabled(model Model, thinkingEnabled bool) {
    20  	if !thinkingEnabled {
    21  		return
    22  	}
    23  	if !modelsToWarnWithThinkingEnabled[string(model)] {
    24  		return
    25  	}
    26  	fmt.Fprintf(
    27  		os.Stderr,
    28  		"Warning: Using Claude with %s and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking\n",
    29  		model,
    30  	)
    31  }