Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions gateway/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2431,21 +2431,19 @@ def _load_provider_routing() -> dict:

@staticmethod
def _load_fallback_model() -> list | dict | None:
"""Load fallback provider chain from config.yaml.
"""Load fallback provider chain from config.yaml with env expansion.

Returns a list of provider dicts (``fallback_providers``), a single
dict (legacy ``fallback_model``), or None if not configured.
AIAgent.__init__ normalizes both formats into a chain.
Uses load_config() so ${VAR} env references are expanded.
"""
try:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current main now refreshes fallback entries per agent create/reuse through _refresh_fallback_model() (gateway/run.py:5011-5041), which still reads raw YAML. Salvage this by routing that method and _try_resolve_fallback_provider() through _load_gateway_runtime_config() as well; changing this static startup reader alone will not cover the active fallback path.

import yaml as _y
cfg_path = _hermes_home / "config.yaml"
if cfg_path.exists():
with open(cfg_path, encoding="utf-8") as _f:
cfg = _y.safe_load(_f) or {}
fb = cfg.get("fallback_providers") or cfg.get("fallback_model") or None
if fb:
return fb
from hermes_cli.config import load_config
cfg = load_config()
fb = cfg.get("fallback_providers") or cfg.get("fallback_model") or None
if fb:
return fb
except Exception:
pass
return None
Expand Down