Skip to content

[Bug]: API server platform ignores fallback_providers config #4954

@drewbitt

Description

@drewbitt

Bug Description

The API server platform (gateway/platforms/api_server.py) never passes fallback_model to AIAgent(), so the fallback chain is always empty when requests come through the OpenAI-compatible API endpoint. Fallback works correctly on all other platforms (Telegram, Discord, Slack, etc.).

Steps to Reproduce

  1. Configure fallback_providers in ~/.hermes/config.yaml
  2. Connect Open WebUI (or any OpenAI-compatible client) to the API server at localhost:8642/v1
  3. Send a message while the primary provider is rate-limited
  4. Observe: retries exhaust, fallback attempt silently does nothing, request fails

Expected Behavior

API server should fall back to the configured fallback_providers chain, same as Telegram/Discord/Slack.

Actual Behavior

_try_activate_fallback() returns False immediately because _fallback_chain is empty — fallback_model was never passed to the AIAgent constructor.

Affected Component

API server platform (gateway/platforms/api_server.py)

Hermes Version

v0.7.0 (2026.4.3)

Root Cause Analysis

In api_server.py, _create_agent() constructs AIAgent without fallback_model:

# api_server.py ~line 432
agent = AIAgent(
    model=model,
    **runtime_kwargs,
    ...
    session_db=self._ensure_session_db(),
    # fallback_model is missing here
)

Compare with gateway/run.py which correctly passes fallback_model=self._fallback_model at lines 4005, 4179, and 5816.

Proposed Fix

Load the fallback config in _create_agent() and pass it through. Either import GatewayApp._load_fallback_model() or replicate the simple yaml load inline.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions