The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tts): lease release reads the requesting profile's keep-warm window
brooklyn!3804baa276f1
diff --git a/hermes_cli/web_routers/audio.py b/hermes_cli/web_routers/audio.pyindex 0b73120e8f7..992ba1a69aa 100644--- a/hermes_cli/web_routers/audio.py+++ b/hermes_cli/web_routers/audio.py@@ -358,7 +358,13 @@ async def tts_lease(payload: TTSLeaseRequest, profile: Optional[str] = None):if payload.active:with _config_profile_scope(profile):return acquire_tts_lease(lease)- return release_tts_lease(lease)+ # Release reads the requester's keep_warm_seconds, but must drop the lease even when+ # that profile is gone — a stuck lease pins the local model in memory.+ try:+ with _config_profile_scope(profile):+ return release_tts_lease(lease)+ except HTTPException:+ return release_tts_lease(lease)try:result = await asyncio.get_running_loop().run_in_executor(None, _apply)diff --git a/tests/hermes_cli/test_web_server_tts_lease.py b/tests/hermes_cli/test_web_server_tts_lease.pyindex c5e55b80430..791e14631d5 100644--- a/tests/hermes_cli/test_web_server_tts_lease.py+++ b/tests/hermes_cli/test_web_server_tts_lease.py@@ -120,6 +120,33 @@ def test_last_release_keeps_model_warm_by_default(client, monkeypatch):assert len(tts_tool_local._piper_voice_cache) == 1+def test_release_reads_keep_warm_from_the_requesting_profile(client, monkeypatch, isolated_profiles):+ from tools import tts_tool_lifecycle, tts_tool_local++ _write_tts_config(isolated_profiles["worker_beta"], {"keep_warm_seconds": 0})+ monkeypatch.setattr(tts_tool_lifecycle, "warm_tts_provider", lambda cfg=None, provider=None: {"action": "loaded", "warmed": True, "provider": "piper"})+ url = "/api/audio/tts-lease?profile=worker_beta"+ client.post(url, json={"lease": "desktop:conversation:abc", "active": True})+ tts_tool_local._piper_voice_cache["voice"] = object()++ last = client.post(url, json={"lease": "desktop:conversation:abc", "active": False}).json()++ assert last["released"] == 1+ assert tts_tool_local._piper_voice_cache == {}+++def test_release_for_a_deleted_profile_still_drops_the_lease(client, monkeypatch):+ from tools import tts_tool_lifecycle++ monkeypatch.setattr(tts_tool_lifecycle, "warm_tts_provider", lambda cfg=None, provider=None: {"action": "noop", "warmed": False, "provider": "piper"})+ client.post("/api/audio/tts-lease", json={"lease": "desktop:read-aloud", "active": True})++ resp = client.post("/api/audio/tts-lease?profile=ghost", json={"lease": "desktop:read-aloud", "active": False})++ assert resp.status_code == 200+ assert resp.json()["leases"] == 0++def test_keep_warm_window_from_config_unloads_after_it_elapses(client, monkeypatch, isolated_profiles):import timefrom tools import tts_tool_lifecycle, tts_tool_local