hermes - ✅(Solved) Fix MiniMax switch_model credential guard test crashes on missing _fallback_chain [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#14864Fetched 2026-04-24 10:44:36
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Timeline (top)
labeled ×5commented ×1cross-referenced ×1

Error Message

E AttributeError: 'AIAgent' object has no attribute '_fallback_chain' run_agent.py:2054

Fix Action

Fix / Workaround

Affected files/lines

  • tests/agent/test_minimax_provider.py:330-343 builds a partial AIAgent via __new__ with AIAgent.__init__ patched out.
  • run_agent.py:2052-2057 assumes self._fallback_chain exists when switch_model() prunes fallback providers after a provider switch.

PR fix notes

PR #14867: fix: default missing fallback state in switch_model

Description (problem / solution / changelog)

Summary

  • default switch_model fallback state when minimal agent fixtures omit _fallback_chain
  • keep provider-switch fallback pruning behavior unchanged for initialized agents
  • add a regression test covering the missing-fallback-attrs path

Testing

  • python3 -m pytest -o addopts= tests/agent/test_minimax_provider.py::TestMinimaxSwitchModelCredentialGuard::test_switch_to_minimax_does_not_resolve_anthropic_token tests/run_agent/test_switch_model_fallback_prune.py

Closes #14864

Changed files

  • run_agent.py (modified, +5/-3)
  • tests/run_agent/test_switch_model_fallback_prune.py (modified, +11/-0)

Code Example

python -m pytest tests/agent/test_minimax_provider.py::TestMinimaxSwitchModelCredentialGuard::test_switch_to_minimax_does_not_resolve_anthropic_token -q -n 0 --tb=short

---

E   AttributeError: 'AIAgent' object has no attribute '_fallback_chain'
run_agent.py:2054

---

1 failed, 563 passed, 1 skipped
RAW_BUFFERClick to expand / collapse

Bug

tests/agent/test_minimax_provider.py::TestMinimaxSwitchModelCredentialGuard::test_switch_to_minimax_does_not_resolve_anthropic_token fails on the current default branch before it can assert the MiniMax credential behavior.

Affected files/lines

  • tests/agent/test_minimax_provider.py:330-343 builds a partial AIAgent via __new__ with AIAgent.__init__ patched out.
  • run_agent.py:2052-2057 assumes self._fallback_chain exists when switch_model() prunes fallback providers after a provider switch.

Evidence / minimal reproduction

From /Users/genie/.hermes/hermes-agent with source venv/bin/activate:

python -m pytest tests/agent/test_minimax_provider.py::TestMinimaxSwitchModelCredentialGuard::test_switch_to_minimax_does_not_resolve_anthropic_token -q -n 0 --tb=short

Actual result:

E   AttributeError: 'AIAgent' object has no attribute '_fallback_chain'
run_agent.py:2054

A larger chunk run also reproduced it:

1 failed, 563 passed, 1 skipped

Why this is a bug

The regression test is intended to guard that switching to MiniMax does not call resolve_anthropic_token() and does not leak Anthropic credentials to a third-party Anthropic-compatible endpoint. A newer fallback-pruning path now crashes first when the test uses a minimally constructed AIAgent, so the credential guard is no longer being exercised by CI.

Expected vs actual

  • Expected: switch_model() completes in this test, resolve_anthropic_token() is not called, and build_anthropic_client() receives the MiniMax API key.
  • Actual: switch_model() raises AttributeError while reading self._fallback_chain.

Suggested investigation direction

Either initialize the fallback fields in this test fixture (_fallback_chain, _fallback_model, etc.) to match the real __init__ invariants, or make switch_model() defensively handle missing fallback attributes if direct/minimally initialized callers are intended to be supported.

extent analysis

TL;DR

Initialize the fallback fields in the test fixture to match the real __init__ invariants or make switch_model() defensively handle missing fallback attributes.

Guidance

  • Verify that the AIAgent object is properly initialized with the required attributes, including _fallback_chain, before calling switch_model().
  • Consider adding a check in switch_model() to handle cases where _fallback_chain is missing, to prevent the AttributeError.
  • Review the test fixture in test_minimax_provider.py to ensure it accurately represents the expected state of the AIAgent object.
  • Investigate the trade-offs between initializing the fallback fields in the test fixture versus making switch_model() more robust to missing attributes.

Example

# In run_agent.py
def switch_model(self):
    if not hasattr(self, '_fallback_chain'):
        # Handle the case where _fallback_chain is missing
        self._fallback_chain = []  # or some other default value
    # Rest of the method implementation

Notes

The suggested fix assumes that the AIAgent object is intended to be used in a state where _fallback_chain may or may not be present. If this is not the case, initializing the fallback fields in the test fixture may be a more appropriate solution.

Recommendation

Apply workaround: Initialize the fallback fields in the test fixture to match the real __init__ invariants, as this is a more targeted solution that addresses the specific test case failure.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING