@@ -62,6 +62,9 @@ func TestTranslateAnthropicToCodex_DefaultsReasoningHighWithSummary(t *testing.T
6262 if summary := gjson .GetBytes (got , "reasoning.summary" ).String (); summary != "auto" {
6363 t .Fatalf ("reasoning.summary = %q, want auto; body=%s" , summary , got )
6464 }
65+ if tier := gjson .GetBytes (got , "service_tier" ); tier .Exists () {
66+ t .Fatalf ("service_tier should be omitted when speed is absent; body=%s" , got )
67+ }
6568}
6669
6770func TestTranslateAnthropicToCodex_ThinkingBudgetDoesNotControlEffort (t * testing.T ) {
@@ -81,6 +84,78 @@ func TestTranslateAnthropicToCodex_ThinkingBudgetDoesNotControlEffort(t *testing
8184 }
8285}
8386
87+ func TestTranslateAnthropicToCodex_SpeedFastMapsToCodexPriority (t * testing.T ) {
88+ cases := []struct {
89+ name string
90+ field string
91+ wantTier bool
92+ }{
93+ {"absent omits priority" , "" , false },
94+ {"speed fast maps to priority" , `,"speed":"fast"` , true },
95+ {"speed standard omits priority" , `,"speed":"standard"` , false },
96+ }
97+ for _ , tc := range cases {
98+ t .Run (tc .name , func (t * testing.T ) {
99+ raw := []byte (`{
100+ "model":"claude-sonnet-4-5",
101+ "messages":[{"role":"user","content":"hello"}]` + tc .field + `
102+ }` )
103+
104+ got , _ , err := TranslateAnthropicToCodexWithModels (raw , "" , []string {"gpt-5.4" })
105+ if err != nil {
106+ t .Fatalf ("TranslateAnthropicToCodexWithModels returned error: %v" , err )
107+ }
108+
109+ tier := gjson .GetBytes (got , "service_tier" )
110+ if tc .wantTier {
111+ if tier .String () != "priority" {
112+ t .Fatalf ("service_tier = %q, want priority; body=%s" , tier .String (), got )
113+ }
114+ if speed := gjson .GetBytes (got , "speed" ); speed .Exists () {
115+ t .Fatalf ("speed should not be forwarded to Codex body; body=%s" , got )
116+ }
117+ return
118+ }
119+ if tier .Exists () {
120+ t .Fatalf ("service_tier should be omitted; body=%s" , got )
121+ }
122+ if speed := gjson .GetBytes (got , "speed" ); speed .Exists () {
123+ t .Fatalf ("speed should not be forwarded to Codex body; body=%s" , got )
124+ }
125+ })
126+ }
127+ }
128+
129+ func TestAnthropicUsageServiceTierResolution (t * testing.T ) {
130+ cases := []struct {
131+ name string
132+ speed string
133+ actual string
134+ want string
135+ }{
136+ {"no fast intent" , "" , "default" , "default" },
137+ {"fast intent upstream default" , "fast" , "default" , "fast" },
138+ {"fast intent upstream priority" , "fast" , "priority" , "fast" },
139+ }
140+ for _ , tc := range cases {
141+ t .Run (tc .name , func (t * testing.T ) {
142+ field := ""
143+ if tc .speed != "" {
144+ field = `,"speed":"` + tc .speed + `"`
145+ }
146+ raw := []byte (`{"model":"claude-opus-4-7","messages":[{"role":"user","content":"hi"}]` + field + `}` )
147+ codexBody , _ , err := TranslateAnthropicToCodexWithModels (raw , "" , []string {"gpt-5.5" })
148+ if err != nil {
149+ t .Fatalf ("TranslateAnthropicToCodexWithModels returned error: %v" , err )
150+ }
151+ got := resolveServiceTier (tc .actual , extractServiceTier (codexBody ))
152+ if got != tc .want {
153+ t .Fatalf ("resolveServiceTier(%q, %q) = %q, want %q" , tc .actual , extractServiceTier (codexBody ), got , tc .want )
154+ }
155+ })
156+ }
157+ }
158+
84159func TestTranslateAnthropicToCodexCanonicalizesDynamicMappedModelAlias (t * testing.T ) {
85160 raw := []byte (`{
86161 "model":"claude-haiku-4-5-20251001",
0 commit comments