From 507b63f86b1464eb8558b05eb3bb7ae04204321f Mon Sep 17 00:00:00 2001 From: Saurabh Date: Sat, 4 Apr 2026 11:32:41 +0530 Subject: [PATCH] fix(api-server): pass fallback_model to AIAgent (#4954) The API server platform never passed fallback_model to AIAgent(), so the fallback provider chain was always empty for requests through the OpenAI-compatible endpoint. Load it via GatewayApp._load_fallback_model() to match the behavior of Telegram/Discord/Slack platforms. --- gateway/platforms/api_server.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gateway/platforms/api_server.py b/gateway/platforms/api_server.py index 86af84307d6..03862a7714d 100644 --- a/gateway/platforms/api_server.py +++ b/gateway/platforms/api_server.py @@ -421,6 +421,11 @@ class APIServerAdapter(BasePlatformAdapter): max_iterations = int(os.getenv("HERMES_MAX_ITERATIONS", "90")) + # Load fallback provider chain so the API server platform has the + # same fallback behaviour as Telegram/Discord/Slack (fixes #4954). + from gateway.run import GatewayApp + fallback_model = GatewayApp._load_fallback_model() + agent = AIAgent( model=model, **runtime_kwargs, @@ -434,6 +439,7 @@ class APIServerAdapter(BasePlatformAdapter): stream_delta_callback=stream_delta_callback, tool_progress_callback=tool_progress_callback, session_db=self._ensure_session_db(), + fallback_model=fallback_model, ) return agent