fix(xmpp_monitor): exclude key7(kimi) from auto-heal switch candidates

zhiwei must stay on ocg-key6 (deepseek-v4-flash) per user decision.
key7 is kimi — different model provider, incompatible model name.
If best_key returns key7, auto_heal logs skip_switch instead of switching.
This commit is contained in:
hmo
2026-07-19 22:09:15 +08:00
parent 9509b80d8b
commit e0f47f9349
2 changed files with 22 additions and 1 deletions
+12
View File
@@ -0,0 +1,12 @@
import sys, json
sys.path.insert(0, '/home/hmo/MoFin')
import importlib, xmpp_logger
importlib.reload(xmpp_logger)
x = xmpp_logger
print("current provider:", x.current_provider())
print("KEY_TO_PROVIDER keys:", list(x.KEY_TO_PROVIDER.keys()))
bk = x.best_key()
print("best_key:", bk["key_id"] if bk else None, "| total_keys:", bk.get("total_keys") if bk else "-")
# Simulate: if best key were key7 (kimi), auto_heal must skip switch
result = x.auto_heal()
print("auto_heal actions:", json.dumps(result["actions"], ensure_ascii=False))
+10 -1
View File
@@ -26,6 +26,8 @@ RESTART_COOLDOWN_FILE = LOG_DIR / "last_restart.txt"
RESTART_COOLDOWN_SEC = 180 # 3 min: don't trigger another restart within 3 min of last RESTART_COOLDOWN_SEC = 180 # 3 min: don't trigger another restart within 3 min of last
# Map AgentsMeeting key_id -> Hermes provider name # Map AgentsMeeting key_id -> Hermes provider name
# NOTE: key7 (kimi) is intentionally NOT in this map — different model provider.
# zhiwei uses deepseek-v4-flash via OCG; auto_heal must never switch to kimi.
KEY_TO_PROVIDER = { KEY_TO_PROVIDER = {
"key1": "ocg-new", "key1": "ocg-new",
"key2": "ocg-old", "key2": "ocg-old",
@@ -442,7 +444,14 @@ def auto_heal():
# 如果 best key 对应的 provider 跟当前不同 → 切换 # 如果 best key 对应的 provider 跟当前不同 → 切换
target_provider = KEY_TO_PROVIDER.get(bk["key_id"]) target_provider = KEY_TO_PROVIDER.get(bk["key_id"])
current = current_provider() current = current_provider()
if target_provider and target_provider != current: if target_provider is None:
# best key is a non-OCG provider (e.g. key7=kimi) — never switch zhiwei there
actions.append({
"action": "skip_switch",
"reason": f"best key {bk['key_id']} is non-OCG (not in KEY_TO_PROVIDER), zhiwei must stay on deepseek",
"best_key": bk["key_id"],
})
elif target_provider != current:
# 只有当 best key 自身至少 weekly ok 才切,否则切过去也白搭 # 只有当 best key 自身至少 weekly ok 才切,否则切过去也白搭
if bk["weekly"]["status"] == "ok": if bk["weekly"]["status"] == "ok":
action = switch_key(bk["key_id"]) action = switch_key(bk["key_id"])