fix(agent): default missing fallback chain on switch

This commit is contained in:
LeonSGP43 2026-04-24 10:46:49 +08:00 committed by Teknium
parent 46451528a5
commit a9fd8d7c88
2 changed files with 16 additions and 3 deletions

View file

@ -78,6 +78,17 @@ def test_switch_with_empty_chain_stays_empty():
assert agent._fallback_model is None
def test_switch_initializes_missing_fallback_attrs():
agent = _make_agent([])
del agent._fallback_chain
del agent._fallback_model
_switch_to_anthropic(agent)
assert agent._fallback_chain == []
assert agent._fallback_model is None
def test_switch_within_same_provider_preserves_chain():
chain = [{"provider": "openrouter", "model": "x-ai/grok-4"}]
agent = _make_agent(chain)