@@ -13,12 +13,14 @@ func TestApplyModelDefaults(t *testing.T) {
1313 t .Parallel ()
1414
1515 boolPtr := func (v bool ) * bool { return & v }
16+ strPtr := func (v string ) * string { return & v }
1617
1718 tests := []struct {
1819 name string
1920 config * latest.ModelConfig
2021 wantBudget * latest.ThinkingBudget // nil means no thinking
2122 wantInterleaved * bool // nil means key must not exist
23+ wantAPIType * string // nil means key must not exist
2224 }{
2325 // --- OpenAI: only o-series gets defaults ---
2426 {
@@ -138,6 +140,28 @@ func TestApplyModelDefaults(t *testing.T) {
138140 config : & latest.ModelConfig {Provider : "openai" , Model : "gpt-4o" , ThinkingBudget : & latest.ThinkingBudget {Effort : "none" }},
139141 },
140142
143+ // --- GitHub Copilot: api_type defaults and overrides ---
144+ {
145+ name : "github-copilot: responses model defaults to openai_responses" ,
146+ config : & latest.ModelConfig {Provider : "github-copilot" , Model : "gpt-5.3-codex" },
147+ wantAPIType : strPtr ("openai_responses" ),
148+ },
149+ {
150+ name : "github-copilot: responses model overrides openai_chatcompletions" ,
151+ config : & latest.ModelConfig {Provider : "github-copilot" , Model : "gpt-5.3-codex" , ProviderOpts : map [string ]any {"api_type" : "openai_chatcompletions" }},
152+ wantAPIType : strPtr ("openai_responses" ),
153+ },
154+ {
155+ name : "github-copilot: responses model preserves explicit openai_responses" ,
156+ config : & latest.ModelConfig {Provider : "github-copilot" , Model : "gpt-5.3-codex" , ProviderOpts : map [string ]any {"api_type" : "openai_responses" }},
157+ wantAPIType : strPtr ("openai_responses" ),
158+ },
159+ {
160+ name : "github-copilot: responses model preserves custom api_type" ,
161+ config : & latest.ModelConfig {Provider : "github-copilot" , Model : "gpt-5.3-codex" , ProviderOpts : map [string ]any {"api_type" : "custom_hypothetical_type" }},
162+ wantAPIType : strPtr ("custom_hypothetical_type" ),
163+ },
164+
141165 // --- Unknown / other providers: no effect ---
142166 {
143167 name : "unknown provider: no effect" ,
@@ -173,6 +197,12 @@ func TestApplyModelDefaults(t *testing.T) {
173197 require .NotNil (t , tt .config .ProviderOpts )
174198 assert .Equal (t , * tt .wantInterleaved , tt .config .ProviderOpts ["interleaved_thinking" ])
175199 }
200+
201+ // Check api_type if wantAPIType is specified.
202+ if tt .wantAPIType != nil {
203+ require .NotNil (t , tt .config .ProviderOpts )
204+ assert .Equal (t , * tt .wantAPIType , tt .config .ProviderOpts ["api_type" ])
205+ }
176206 })
177207 }
178208}
@@ -265,6 +295,18 @@ func TestApplyProviderDefaults_DoesNotModifyOriginal(t *testing.T) {
265295 assert .Equal (t , "original_value" , original .ProviderOpts ["custom_key" ])
266296}
267297
298+ func TestIsCopilotResponsesModel (t * testing.T ) {
299+ t .Parallel ()
300+
301+ assert .True (t , isCopilotResponsesModel ("gpt-5.3-codex" ))
302+ assert .True (t , isCopilotResponsesModel ("gpt-5.2-codex" ))
303+ assert .True (t , isCopilotResponsesModel ("gpt-5.4-mini" ))
304+ assert .True (t , isCopilotResponsesModel ("gpt-5.4-nano" ))
305+ assert .False (t , isCopilotResponsesModel ("gpt-4o" ))
306+ assert .False (t , isCopilotResponsesModel ("claude-sonnet-4-5" ))
307+ assert .False (t , isCopilotResponsesModel ("" ))
308+ }
309+
268310// TestApplyProviderDefaults_InheritsAuthFromProviderConfig verifies that a
269311// ProviderConfig's Auth block is inherited by models that don't override it,
270312// while a model-level Auth always wins.
0 commit comments