MCPcopy Index your code
hub / github.com/simstudioai/sim / buildThinkingConfig

Function buildThinkingConfig

apps/sim/providers/anthropic/core.ts:118–150  ·  view source on GitHub ↗

* Builds the thinking configuration for the Anthropic API based on model capabilities and level. * * - Fable 5, Sonnet 5, Opus 4.8, Opus 4.7: Uses adaptive thinking only (no extended thinking support) * - Opus 4.6, Sonnet 4.6: Uses adaptive thinking with effort parameter * - Other models: Uses b

(
  modelId: string,
  thinkingLevel: string
)

Source from the content-addressed store, hash-verified

116 * Returns both the thinking config and optional output_config for adaptive thinking.
117 */
118function buildThinkingConfig(
119 modelId: string,
120 thinkingLevel: string
121): {
122 thinking: { type: 'enabled'; budget_tokens: number } | { type: 'adaptive' }
123 outputConfig?: { effort: string }
124} | null {
125 const capability = getThinkingCapability(modelId)
126 if (!capability || !capability.levels.includes(thinkingLevel)) {
127 return null
128 }
129
130 // Models with effort support use adaptive thinking
131 if (supportsAdaptiveThinking(modelId)) {
132 return {
133 thinking: { type: 'adaptive' },
134 outputConfig: { effort: thinkingLevel },
135 }
136 }
137
138 // Other models use budget_tokens-based extended thinking
139 const budgetTokens = THINKING_BUDGET_TOKENS[thinkingLevel]
140 if (!budgetTokens) {
141 return null
142 }
143
144 return {
145 thinking: {
146 type: 'enabled',
147 budget_tokens: budgetTokens,
148 },
149 }
150}
151
152/**
153 * The Anthropic SDK requires streaming for non-streaming requests when max_tokens exceeds

Callers 1

Calls 2

getThinkingCapabilityFunction · 0.90
supportsAdaptiveThinkingFunction · 0.85

Tested by

no test coverage detected