From 21afc9502aa3c78fb88496d0dc7c68598729b6fa Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 15 Apr 2026 16:10:56 -0700 Subject: [PATCH] fix: respect explicit api_mode for custom GPT-5 endpoints (#10473) (#10548) The GPT-5 auto-upgrade logic unconditionally overrode api_mode to codex_responses for any model starting with gpt-5, even when the user explicitly set api_mode=chat_completions. Custom proxies that serve GPT-5 via /chat/completions became unusable. Fix: check api_mode is None before the override fires. If the caller passed any explicit api_mode, it is final -- no auto-upgrade. Closes #10473 --- run_agent.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/run_agent.py b/run_agent.py index 3a017f739..d229dcfe0 100644 --- a/run_agent.py +++ b/run_agent.py @@ -721,8 +721,11 @@ class AIAgent: # Responses there. ACP runtimes are excluded: CopilotACPClient # handles its own routing and does not implement the Responses API # surface. + # When api_mode was explicitly provided, respect it — the user + # knows what their endpoint supports (#10473). if ( - self.api_mode == "chat_completions" + api_mode is None + and self.api_mode == "chat_completions" and self.provider != "copilot-acp" and not str(self.base_url or "").lower().startswith("acp://copilot") and not str(self.base_url or "").lower().startswith("acp+tcp://")