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.
This commit is contained in:
Saurabh 2026-04-04 11:32:41 +05:30 committed by Teknium
parent 7f853ba7b6
commit 507b63f86b

View file

@ -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