Skip to content

ACP adapter does not pass fallback_providers to AIAgent — model failover broken in editor integrations #18452

@hitken

Description

@hitken

Bug Description

When using Hermes via ACP (Obsidian Agent Client, VS Code, JetBrains, Zed, etc.), the fallback_providers configured in config.yaml are never passed to AIAgent(). This means when the primary model encounters an error (rate limit, overload, auth failure), the agent cannot automatically switch to a configured fallback provider — it just fails.

The CLI and gateway both correctly read fallback_providers from config and pass them to AIAgent(fallback_model=...), but the ACP adapter does not.

Reproduction

  1. Configure fallback_providers in ~/.hermes/config.yaml:
    fallback_providers:
      - model: glm-5-turbo
        provider: zhipu
      - model: qwen3.6-plus
        provider: bailian
  2. Set primary model to a provider that may error (e.g. during peak hours)
  3. Connect via Obsidian Agent Client (ACP)
  4. When primary model errors, observe that fallback does NOT activate — session fails instead

Root Cause

In acp_adapter/session.py, _make_agent() builds the kwargs dict for AIAgent() but never includes fallback_model. Compare:

  • CLI (cli.py:2106-2110): reads fallback_providers from config, passes as fallback_model=self._fallback_model to AIAgent()
  • Gateway (gateway/session.py): also passes fallback_model
  • ACP (acp_adapter/session.py:565-597): kwargs has no fallback_model key at all

Result: AIAgent.__init__ sets self._fallback_chain = [] and self._fallback_index = 0, so error_classifier.py correctly flags should_fallback=True but the main loop has no fallback chain to iterate over.

Fix

Add fallback_providers loading in acp_adapter/session.py _make_agent(), right before the session_db assignment:

        # Pass fallback_providers from config so ACP agents can fail over
        # when the primary model errors (same as CLI does in cli.py).
        try:
            fb = config.get("fallback_providers") or config.get("fallback_model") or []
            if isinstance(fb, dict):
                fb = [fb] if fb.get("provider") and fb.get("model") else []
            if fb:
                kwargs["fallback_model"] = fb
        except Exception:
            logger.debug("Could not load fallback_providers for ACP agent", exc_info=True)

Environment

  • Hermes version: v0.10.2+
  • Platform: ACP (any editor integration)
  • All providers affected

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existsarea/configConfig system, migrations, profilescomp/acpAgent Communication Protocol adaptertype/bugSomething isn't working

    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