Coverage for merco/core/recovery/model_fallback.py: 55%
11 statements
« prev ^ index » next coverage.py v7.15.0, created at 2026-07-07 14:04 +0800
« prev ^ index » next coverage.py v7.15.0, created at 2026-07-07 14:04 +0800
1"""ModelFallbackRecovery — switches to a fallback model on failure."""
2from __future__ import annotations
4from merco.core.pipeline import Recovery, RecoveryContext
7class ModelFallbackRecovery(Recovery):
8 """模型降级:当前模型不可用时切换到备选 [框架预留]
10 需要 Agent 支持 switch_model 标志位后启用。
11 """
13 name = "model_fallback"
15 def __init__(self, fallback_model: str = ""):
16 self.fallback_model = fallback_model
18 async def attempt(self, ctx: RecoveryContext) -> bool:
19 if not self.fallback_model:
20 return False
21 ctx.switch_model = self.fallback_model
22 return True