feat: publish sanitized custom.97 source
This commit is contained in:
1022 files changed
+69903
-19207
No files matched your search
@@ -26,15 +26,25 @@ type claudeCapabilities struct {
|
||||
supportsManual bool
|
||||
defaultThinking bool
|
||||
supportsDisable bool
|
||||
supportsEffort bool
|
||||
supportsXHigh bool
|
||||
supportsMax bool
|
||||
strictSampling bool
|
||||
// disableAsBetweenTools marks models whose lowest thinking setting is
|
||||
// {"type":"between_tools"} instead of {"type":"disabled"}.
|
||||
disableAsBetweenTools bool
|
||||
supportsEffort bool
|
||||
supportsXHigh bool
|
||||
supportsMax bool
|
||||
strictSampling bool
|
||||
// offEffortAtMostHigh marks models that accept effort high or below only
|
||||
// while thinking is off (disabled or between_tools).
|
||||
offEffortAtMostHigh bool
|
||||
// defaultEffort is the effort the model runs at when a request sets none:
|
||||
// medium on Claude Opus 5.5 and Haiku 5.5 and high on every other model
|
||||
// (https://platform.claude.com/docs/en/build-with-claude/effort).
|
||||
defaultEffort Effort
|
||||
}
|
||||
|
||||
func claudeCapabilitiesFor(model string) claudeCapabilities {
|
||||
model = strings.ToLower(model)
|
||||
capabilities := claudeCapabilities{supportsManual: true, supportsDisable: true}
|
||||
capabilities := claudeCapabilities{supportsManual: true, supportsDisable: true, defaultEffort: EffortHigh}
|
||||
|
||||
switch {
|
||||
case strings.HasPrefix(model, "claude-fable-5"),
|
||||
@@ -43,6 +53,7 @@ func claudeCapabilitiesFor(model string) claudeCapabilities {
|
||||
capabilities.supportsManual = false
|
||||
capabilities.defaultThinking = true
|
||||
capabilities.supportsDisable = false
|
||||
capabilities.supportsEffort = true
|
||||
capabilities.supportsXHigh = true
|
||||
capabilities.supportsMax = true
|
||||
capabilities.strictSampling = true
|
||||
@@ -50,17 +61,41 @@ func claudeCapabilitiesFor(model string) claudeCapabilities {
|
||||
capabilities.adaptive = true
|
||||
capabilities.defaultThinking = true
|
||||
capabilities.supportsDisable = false
|
||||
capabilities.supportsEffort = true
|
||||
capabilities.supportsMax = true
|
||||
capabilities.strictSampling = true
|
||||
case strings.HasPrefix(model, "claude-opus-5-5"),
|
||||
strings.HasPrefix(model, "claude-sonnet-5-5"):
|
||||
// Opus 5.5 cannot turn thinking off at all; Sonnet 5.5 turns it off
|
||||
// with between_tools, which takes effort high or below only.
|
||||
capabilities.adaptive = true
|
||||
capabilities.supportsManual = false
|
||||
capabilities.defaultThinking = true
|
||||
capabilities.supportsDisable = false
|
||||
capabilities.disableAsBetweenTools = strings.HasPrefix(model, "claude-sonnet-5-5")
|
||||
capabilities.offEffortAtMostHigh = capabilities.disableAsBetweenTools
|
||||
if strings.HasPrefix(model, "claude-opus-5-5") {
|
||||
capabilities.defaultEffort = EffortMedium
|
||||
}
|
||||
capabilities.supportsEffort = true
|
||||
capabilities.supportsXHigh = true
|
||||
capabilities.supportsMax = true
|
||||
capabilities.strictSampling = true
|
||||
case strings.HasPrefix(model, "claude-opus-5"),
|
||||
strings.HasPrefix(model, "claude-sonnet-5"),
|
||||
strings.HasPrefix(model, "claude-haiku-5"),
|
||||
strings.HasPrefix(model, "claude-opus-4-8"),
|
||||
strings.HasPrefix(model, "claude-opus-4-7"):
|
||||
capabilities.adaptive = true
|
||||
capabilities.supportsManual = false
|
||||
if strings.HasPrefix(model, "claude-opus-5") || strings.HasPrefix(model, "claude-sonnet-5") {
|
||||
if strings.HasPrefix(model, "claude-opus-5") || strings.HasPrefix(model, "claude-sonnet-5") || strings.HasPrefix(model, "claude-haiku-5") {
|
||||
capabilities.defaultThinking = true
|
||||
}
|
||||
// Opus 5 and Haiku 5.5 reject disabled thinking with xhigh or max.
|
||||
capabilities.offEffortAtMostHigh = strings.HasPrefix(model, "claude-opus-5") || strings.HasPrefix(model, "claude-haiku-5")
|
||||
if strings.HasPrefix(model, "claude-haiku-5") {
|
||||
capabilities.defaultEffort = EffortMedium
|
||||
}
|
||||
capabilities.supportsEffort = true
|
||||
capabilities.supportsXHigh = true
|
||||
capabilities.supportsMax = true
|
||||
@@ -97,12 +132,6 @@ func RenderClaude(model string, intent Intent, maxTokens *uint, adapterBudgetPer
|
||||
diagnostics = append(diagnostics, normalizeDiagnostics...)
|
||||
}
|
||||
capabilities := claudeCapabilitiesFor(model)
|
||||
if disabledWithEffort {
|
||||
diagnostics = append(diagnostics, claudeReasoningDiagnostic(
|
||||
"claude_disabled_effort_ignored",
|
||||
fmt.Sprintf("model %q cannot apply effort %q while thinking is disabled; the effort was ignored", model, intent.Effort),
|
||||
))
|
||||
}
|
||||
if !intent.HasStrength() {
|
||||
if intent.IncludeThoughts != nil && capabilities.adaptive && capabilities.defaultThinking {
|
||||
thinking := &dto.Thinking{Type: "adaptive"}
|
||||
@@ -113,17 +142,43 @@ func RenderClaude(model string, intent Intent, maxTokens *uint, adapterBudgetPer
|
||||
}
|
||||
return ClaudeRender{
|
||||
Thinking: thinking,
|
||||
EffectiveEffort: EffortHigh,
|
||||
EffectiveEffort: capabilities.defaultEffort,
|
||||
ClearSampling: capabilities.strictSampling,
|
||||
}, nil
|
||||
}
|
||||
if capabilities.defaultThinking {
|
||||
return ClaudeRender{EffectiveEffort: EffortHigh, ClearSampling: capabilities.strictSampling}, nil
|
||||
return ClaudeRender{EffectiveEffort: capabilities.defaultEffort, ClearSampling: capabilities.strictSampling}, nil
|
||||
}
|
||||
return ClaudeRender{ClearSampling: capabilities.strictSampling}, nil
|
||||
}
|
||||
|
||||
if intent.Mode == ModeDisabled || intent.Effort == EffortNone {
|
||||
// Effort works without thinking, so a requested level is sent at one
|
||||
// the model accepts while thinking is off.
|
||||
outputEffort := Effort("")
|
||||
if disabledWithEffort && (capabilities.supportsDisable || capabilities.disableAsBetweenTools) {
|
||||
outputEffort = ClaudeEffort(model, intent.Effort)
|
||||
if capabilities.offEffortAtMostHigh && (outputEffort == EffortXHigh || outputEffort == EffortMax) {
|
||||
outputEffort = EffortHigh
|
||||
}
|
||||
diagnostics = append(diagnostics, claudeEffortDiagnostics(model, intent.Effort, outputEffort)...)
|
||||
}
|
||||
if capabilities.disableAsBetweenTools {
|
||||
// between_tools takes no other thinking field and runs at the
|
||||
// default effort or the requested one, both within its "high or
|
||||
// below" limit.
|
||||
diagnostics = append(diagnostics, claudeReasoningDiagnostic(
|
||||
"claude_thinking_disable_as_between_tools",
|
||||
fmt.Sprintf("model %q rejects disabled thinking; using between_tools, its lowest thinking setting", model),
|
||||
))
|
||||
return ClaudeRender{
|
||||
Thinking: &dto.Thinking{Type: "between_tools"},
|
||||
OutputEffort: outputEffort,
|
||||
EffectiveEffort: EffortNone,
|
||||
ClearSampling: capabilities.strictSampling,
|
||||
Diagnostics: diagnostics,
|
||||
}, nil
|
||||
}
|
||||
if !capabilities.supportsDisable {
|
||||
diagnostics = append(diagnostics, claudeReasoningDiagnostic(
|
||||
"claude_thinking_disable_unsupported",
|
||||
@@ -138,8 +193,7 @@ func RenderClaude(model string, intent Intent, maxTokens *uint, adapterBudgetPer
|
||||
thinking.Display = "omitted"
|
||||
}
|
||||
}
|
||||
outputEffort := Effort("")
|
||||
effectiveEffort := EffortHigh
|
||||
effectiveEffort := capabilities.defaultEffort
|
||||
if capabilities.supportsEffort {
|
||||
outputEffort = EffortLow
|
||||
effectiveEffort = EffortLow
|
||||
@@ -156,6 +210,7 @@ func RenderClaude(model string, intent Intent, maxTokens *uint, adapterBudgetPer
|
||||
}
|
||||
return ClaudeRender{
|
||||
Thinking: &dto.Thinking{Type: "disabled"},
|
||||
OutputEffort: outputEffort,
|
||||
EffectiveEffort: EffortNone,
|
||||
ClearSampling: capabilities.strictSampling,
|
||||
Diagnostics: diagnostics,
|
||||
@@ -175,7 +230,7 @@ func RenderClaude(model string, intent Intent, maxTokens *uint, adapterBudgetPer
|
||||
effort = EffortFromBudget(*intent.BudgetTokens)
|
||||
}
|
||||
if effort == "" && intent.Mode == ModeEnabled {
|
||||
effort = EffortHigh
|
||||
effort = capabilities.defaultEffort
|
||||
}
|
||||
normalizedEffort := normalizeClaudeEffort(effort, capabilities)
|
||||
if effort != "" && normalizedEffort != effort {
|
||||
@@ -187,7 +242,7 @@ func RenderClaude(model string, intent Intent, maxTokens *uint, adapterBudgetPer
|
||||
effort = normalizedEffort
|
||||
effectiveEffort := effort
|
||||
if effectiveEffort == "" && intent.Mode == ModeAdaptive {
|
||||
effectiveEffort = EffortHigh
|
||||
effectiveEffort = capabilities.defaultEffort
|
||||
}
|
||||
|
||||
// Claude effort can be used without enabling thinking. Preserve that
|
||||
@@ -227,11 +282,22 @@ func RenderClaude(model string, intent Intent, maxTokens *uint, adapterBudgetPer
|
||||
))
|
||||
intent.Mode = ModeEnabled
|
||||
if intent.Effort == "" {
|
||||
intent.Effort = EffortHigh
|
||||
intent.Effort = capabilities.defaultEffort
|
||||
}
|
||||
}
|
||||
if intent.Mode == ModeUnset {
|
||||
return ClaudeRender{OutputEffort: intent.Effort, EffectiveEffort: intent.Effort, Diagnostics: diagnostics}, nil
|
||||
// Known models get the effort they accept. They think only when asked,
|
||||
// so a removed effort leaves none.
|
||||
effort := intent.Effort
|
||||
if isKnownClaudeModel(model) {
|
||||
effort = ClaudeEffort(model, intent.Effort)
|
||||
diagnostics = append(diagnostics, claudeEffortDiagnostics(model, intent.Effort, effort)...)
|
||||
}
|
||||
effectiveEffort := effort
|
||||
if effectiveEffort == "" {
|
||||
effectiveEffort = EffortNone
|
||||
}
|
||||
return ClaudeRender{OutputEffort: effort, EffectiveEffort: effectiveEffort, Diagnostics: diagnostics}, nil
|
||||
}
|
||||
var raisedMaxTokens *uint
|
||||
if maxTokens == nil || *maxTokens <= 1024 {
|
||||
@@ -289,9 +355,8 @@ func RenderClaude(model string, intent Intent, maxTokens *uint, adapterBudgetPer
|
||||
} else if effectiveEffort == "" {
|
||||
effectiveEffort = EffortFromBudget(budget)
|
||||
}
|
||||
outputEffort := Effort("")
|
||||
if capabilities.supportsEffort && intent.Effort != "" {
|
||||
outputEffort = normalizeClaudeEffort(intent.Effort, capabilities)
|
||||
outputEffort := ClaudeEffort(model, intent.Effort)
|
||||
if outputEffort != "" {
|
||||
effectiveEffort = outputEffort
|
||||
}
|
||||
thinking := &dto.Thinking{Type: "enabled", BudgetTokens: &budget}
|
||||
@@ -322,6 +387,25 @@ func claudeReasoningDiagnostic(code string, message string) types.ConversionDiag
|
||||
}
|
||||
}
|
||||
|
||||
// claudeEffortDiagnostics reports a requested effort that is sent at another
|
||||
// level or removed because the model takes none.
|
||||
func claudeEffortDiagnostics(model string, requested Effort, sent Effort) []types.ConversionDiagnostic {
|
||||
switch {
|
||||
case requested == "" || requested == EffortNone || requested == sent:
|
||||
return nil
|
||||
case sent == "":
|
||||
return []types.ConversionDiagnostic{claudeReasoningDiagnostic(
|
||||
"claude_effort_unsupported",
|
||||
fmt.Sprintf("model %q does not support effort %q; the effort was removed", model, requested),
|
||||
)}
|
||||
default:
|
||||
return []types.ConversionDiagnostic{claudeReasoningDiagnostic(
|
||||
"claude_effort_adjusted",
|
||||
fmt.Sprintf("model %q does not support effort %q with the selected thinking mode; using %q", model, requested, sent),
|
||||
)}
|
||||
}
|
||||
}
|
||||
|
||||
// ClaudeUsesManualThinking reports whether an exact numeric budget is rendered
|
||||
// as legacy extended thinking rather than being reduced to adaptive effort.
|
||||
func ClaudeUsesManualThinking(model string, intent Intent) bool {
|
||||
@@ -333,12 +417,39 @@ func IsKnownClaudeModel(model string) bool {
|
||||
return isKnownClaudeModel(model)
|
||||
}
|
||||
|
||||
// ClaudeDefaultEffort is the effort the model runs at when a request sets
|
||||
// none.
|
||||
func ClaudeDefaultEffort(model string) Effort {
|
||||
return claudeCapabilitiesFor(model).defaultEffort
|
||||
}
|
||||
|
||||
// ClaudeEffort returns the effort level the model accepts in place of the
|
||||
// requested one. It returns empty when no effort is requested or the model
|
||||
// takes none, which includes models missing from the capability table.
|
||||
func ClaudeEffort(model string, effort Effort) Effort {
|
||||
capabilities := claudeCapabilitiesFor(model)
|
||||
if !capabilities.supportsEffort || effort == "" || effort == EffortNone {
|
||||
return ""
|
||||
}
|
||||
return normalizeClaudeEffort(effort, capabilities)
|
||||
}
|
||||
|
||||
// ResolveClaudeDefault makes the Claude model's default thinking explicit for
|
||||
// a non-Claude target: no intent becomes adaptive thinking on models that
|
||||
// think by default, and thinking without a strength takes the model's
|
||||
// default effort.
|
||||
func ResolveClaudeDefault(model string, intent Intent) Intent {
|
||||
if intent.HasStrength() || !claudeCapabilitiesFor(model).defaultThinking {
|
||||
return intent
|
||||
capabilities := claudeCapabilitiesFor(model)
|
||||
switch {
|
||||
case !intent.HasStrength():
|
||||
if !capabilities.defaultThinking {
|
||||
return intent
|
||||
}
|
||||
intent.Mode = ModeAdaptive
|
||||
intent.Effort = capabilities.defaultEffort
|
||||
case intent.Effort == "" && intent.BudgetTokens == nil && (intent.Mode == ModeAdaptive || intent.Mode == ModeEnabled):
|
||||
intent.Effort = capabilities.defaultEffort
|
||||
}
|
||||
intent.Mode = ModeAdaptive
|
||||
intent.Effort = EffortHigh
|
||||
return intent
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user