@@ -43,6 +43,11 @@ func isOpenAICompatibleProvider(providerType string) bool {
4343 return exists && alias .APIType == "openai"
4444}
4545
46+ // IsGithubCopilotProvider returns true if the provider type is "github-copilot".
47+ func isGithubCopilotProvider (providerType string ) bool {
48+ return providerType == "github-copilot"
49+ }
50+
4651// ---------------------------------------------------------------------------
4752// Provider defaults
4853// ---------------------------------------------------------------------------
@@ -180,6 +185,9 @@ func cloneModelConfig(cfg *latest.ModelConfig) *latest.ModelConfig {
180185//
181186// NOTE: max_tokens is NOT set here; see teamloader and runtime/model_switcher.
182187func applyModelDefaults (cfg * latest.ModelConfig ) {
188+ // Set appropriate github copilot api_type.
189+ applyGithubCopilotAPIType (cfg )
190+
183191 // Explicitly disabled → normalise to nil so providers never see it.
184192 if cfg .ThinkingBudget .IsDisabled () {
185193 cfg .ThinkingBudget = nil
@@ -225,6 +233,18 @@ func ensureInterleavedThinking(cfg *latest.ModelConfig, providerType string) {
225233 }
226234}
227235
236+ func applyGithubCopilotAPIType (cfg * latest.ModelConfig ) {
237+ if isGithubCopilotProvider (cfg .Provider ) && isCopilotResponsesModel (cfg .Model ) {
238+ if cfg .ProviderOpts == nil {
239+ cfg .ProviderOpts = make (map [string ]any )
240+ }
241+ // If it's not set, or was set to openai_chatcompletions by the generic fallback, override it.
242+ if apiType , ok := cfg .ProviderOpts ["api_type" ].(string ); ! ok || apiType == "" || apiType == "openai_chatcompletions" {
243+ cfg .ProviderOpts ["api_type" ] = "openai_responses"
244+ }
245+ }
246+ }
247+
228248// ---------------------------------------------------------------------------
229249// Model-name predicates
230250// ---------------------------------------------------------------------------
@@ -281,3 +301,14 @@ func isGeminiProModel(model string) bool {
281301func isGeminiFlashModel (model string ) bool {
282302 return strings .HasPrefix (gemini3Family (model ), "flash" )
283303}
304+
305+ // isCopilotResponsesModel returns true if the model is a GitHub Copilot model that requires the openai_responses API type.
306+ func isCopilotResponsesModel (model string ) bool {
307+ codex := map [string ]bool {
308+ "gpt-5.3-codex" : true ,
309+ "gpt-5.2-codex" : true ,
310+ "gpt-5.4-mini" : true ,
311+ "gpt-5.4-nano" : true ,
312+ }
313+ return codex [model ]
314+ }
0 commit comments