Files
sub2api/backend/internal/pkg/claude/constants_model_test.go
T
xcrong d56f5e7879 feat(gateway): adapt Claude Haiku 5.5
Closes #7919. Wire claude-haiku-5-5 (released 2026-10-07) across model
registry, effort catalog, pricing, billing, validation and Codex
descriptors, following the opus-5-5/sonnet-5-5 template and the official
migration guide + overview specs.

- registry: DefaultModels entry (fixed ID, no date suffix per guide)
- effort: full low/medium/high/xhigh/max family + IsHaiku55 +
  claude-haiku-5.5 dotted normalization (official default: medium)
- pricing catalog: 1M/128k limits, base (<=100k) prices and
  *_above_100k_tokens absolute prices; the existing ladder derivation
  yields threshold=100000 with uniform 5x multipliers, matching the
  official two-tier table exactly (cache tiers follow input x5)
- billing/pricing fallbacks carry the same tier so a missing catalog
  entry can never silently bill >100k prompts at base rate
- validation: adaptive-only thinking (enabled always 400; disabled 400
  at xhigh/max), sonnet-style sampling locks, temp+top_p combo rejected,
  forced tool_choice explicitly allowed (differs from opus/sonnet)
- oauth mimicry: skip temperature:1 top-up when top_p is present on
  sampling-locked models (sonnet-5-5 included), otherwise the gateway
  manufactures the temp+top_p 400 itself
- toolset beta filter + Codex 1M context cover haiku-5-5
- Bedrock/Antigravity mappings intentionally left out (no 5.5 entries
  exist there at all, same as opus-5-5); Vertex passes the fixed ID
  through untouched
2026-10-09 10:07:36 +08:00

59 lines
1.4 KiB
Go

package claude
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestDefaultModelsContainsClaudeFable51(t *testing.T) {
t.Parallel()
for _, model := range DefaultModels {
if model.ID == "claude-fable-5-1" {
require.Equal(t, "Claude Fable 5.1", model.DisplayName)
require.Equal(t, "2026-09-01T00:00:00Z", model.CreatedAt)
return
}
}
t.Fatal("claude-fable-5-1 missing from DefaultModels")
}
func TestDefaultModelsContainsOpus55(t *testing.T) {
for _, model := range DefaultModels {
if model.ID == "claude-opus-5-5" {
if model.DisplayName != "Claude Opus 5.5" || model.CreatedAt != "2026-09-22T00:00:00Z" {
t.Fatalf("unexpected Opus 5.5 descriptor: %+v", model)
}
return
}
}
t.Fatal("claude-opus-5-5 missing")
}
func TestDefaultModelsContainsSonnet55(t *testing.T) {
t.Parallel()
for _, model := range DefaultModels {
if model.ID == "claude-sonnet-5-5" {
require.Equal(t, "Claude Sonnet 5.5", model.DisplayName)
require.Equal(t, "2026-09-28T00:00:00Z", model.CreatedAt)
return
}
}
t.Fatal("claude-sonnet-5-5 missing from DefaultModels")
}
func TestDefaultModelsContainsHaiku55(t *testing.T) {
t.Parallel()
for _, model := range DefaultModels {
if model.ID == "claude-haiku-5-5" {
require.Equal(t, "Claude Haiku 5.5", model.DisplayName)
require.Equal(t, "2026-10-07T00:00:00Z", model.CreatedAt)
return
}
}
t.Fatal("claude-haiku-5-5 missing from DefaultModels")
}