@@ -174,8 +174,7 @@ func (a *Applier) normalizeClaudeBudget(body []byte, budgetTokens int, modelInfo
174174 // Ensure the request satisfies Claude constraints:
175175 // 1) Determine effective max_tokens (request overrides model default)
176176 // 2) If budget_tokens >= max_tokens, reduce budget_tokens to max_tokens-1
177- // 3) If the adjusted budget falls below the model minimum, try raising max_tokens
178- // (clamped to MaxCompletionTokens); disable thinking if constraints are unsatisfiable
177+ // 3) If the adjusted budget falls below the model minimum, leave the request unchanged
179178 // 4) If max_tokens came from model default, write it back into the request
180179
181180 effectiveMax , setDefaultMax := a .effectiveMaxTokens (body , modelInfo )
@@ -194,28 +193,8 @@ func (a *Applier) normalizeClaudeBudget(body []byte, budgetTokens int, modelInfo
194193 minBudget = modelInfo .Thinking .Min
195194 }
196195 if minBudget > 0 && adjustedBudget > 0 && adjustedBudget < minBudget {
197- // Enforcing budget_tokens < max_tokens pushed the budget below the model minimum.
198- // Try raising max_tokens to fit the original budget.
199- needed := budgetTokens + 1
200- maxAllowed := 0
201- if modelInfo != nil {
202- maxAllowed = modelInfo .MaxCompletionTokens
203- }
204- if maxAllowed > 0 && needed > maxAllowed {
205- // Cannot use original budget; cap max_tokens at model limit.
206- needed = maxAllowed
207- }
208- cappedBudget := needed - 1
209- if cappedBudget < minBudget {
210- // Impossible to satisfy both budget >= minBudget and budget < max_tokens
211- // within the model's completion limit. Disable thinking entirely.
212- body , _ = sjson .DeleteBytes (body , "thinking" )
213- return body
214- }
215- body , _ = sjson .SetBytes (body , "max_tokens" , needed )
216- if cappedBudget != budgetTokens {
217- body , _ = sjson .SetBytes (body , "thinking.budget_tokens" , cappedBudget )
218- }
196+ // If enforcing the max_tokens constraint would push the budget below the model minimum,
197+ // leave the request unchanged.
219198 return body
220199 }
221200
0 commit comments