fix: support xhigh reasoning effort in usage records for Claude Messages API

Closes #1732
This commit is contained in:
erio
2026-04-19 18:05:25 +08:00
parent 51af8df31d
commit 6530776a62
3 changed files with 11 additions and 3 deletions

View File

@@ -962,7 +962,7 @@ func NormalizeClaudeOutputEffort(raw string) *string {
return nil
}
switch value {
case "low", "medium", "high", "max":
case "low", "medium", "high", "xhigh", "max":
return &value
default:
return nil

View File

@@ -1149,6 +1149,11 @@ func TestParseGatewayRequest_OutputEffort(t *testing.T) {
body: `{"model":"claude-opus-4-6","output_config":{"effort":"max"},"messages":[]}`,
wantEffort: "max",
},
{
name: "output_config.effort xhigh",
body: `{"model":"claude-opus-4-7","output_config":{"effort":"xhigh"},"messages":[]}`,
wantEffort: "xhigh",
},
{
name: "output_config without effort",
body: `{"model":"claude-opus-4-6","output_config":{},"messages":[]}`,
@@ -1186,9 +1191,10 @@ func TestNormalizeClaudeOutputEffort(t *testing.T) {
{"LOW", strPtr("low")},
{"Max", strPtr("max")},
{" medium ", strPtr("medium")},
{"xhigh", strPtr("xhigh")},
{"XHIGH", strPtr("xhigh")},
{"", nil},
{"unknown", nil},
{"xhigh", nil},
}
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {

View File

@@ -193,7 +193,9 @@ export function formatReasoningEffort(effort: string | null | undefined): string
return 'High'
case 'xhigh':
case 'extrahigh':
return 'Xhigh'
return 'XHigh'
case 'max':
return 'Max'
case 'none':
case 'minimal':
return '-'