Recover router availability after failed profile switch

This commit is contained in:
Mikei386
2026-09-02 22:03:35 +02:00
parent b3e86cc7ae
commit 4153e535d3
2 changed files with 17 additions and 0 deletions
+12
View File
@@ -24,6 +24,7 @@ from router_support import ( # noqa: E402
load_profile_registry,
)
from ai_profile_router import ( # noqa: E402
STATE,
_cap_chat_generation,
_context_matches,
_inject_global_system_policy,
@@ -31,6 +32,7 @@ from ai_profile_router import ( # noqa: E402
_normalize_chat_images,
_normalize_llamacpp_reasoning,
_request_has_image,
switch_profile,
)
@@ -94,6 +96,16 @@ class ProfileRegistryTests(unittest.TestCase):
self.assertFalse(_context_matches(80000, 76800))
self.assertFalse(_context_matches(80000, 82000))
def test_ready_profile_clears_stale_unavailable_flag(self) -> None:
with STATE.avail_lock:
STATE.qwen_unavailable = True
status = {"reachable": True, "model": "qwen-medium", "ctx": 160000}
with patch("ai_profile_router.current_profile", return_value="medium"), \
patch("ai_profile_router.upstream_status", return_value=status):
switch_profile("medium")
with STATE.avail_lock:
self.assertFalse(STATE.qwen_unavailable)
class ChatImageInputTests(unittest.TestCase):
def test_small_png_data_url_is_accepted(self) -> None: