The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tts): uncache the tts_voices check so a provider switch shows it at once
Teknium10a30ead42d2
diff --git a/tests/tools/test_tts_voice_selection.py b/tests/tools/test_tts_voice_selection.pyindex 0e0b50f1bb0..c702cdcd18a 100644--- a/tests/tools/test_tts_voice_selection.py+++ b/tests/tools/test_tts_voice_selection.py@@ -101,3 +101,25 @@ def test_tts_voices_rejects_a_non_numeric_library_page():patch("tools.tts_voices_tool.httpx.get") as get:result = json.loads(tts_voices_tool.tts_voices_tool(source="library", page="tok-2"))assert not result["success"] and get.call_count == 0+++def test_provider_switch_shows_and_hides_tts_voices_at_once(monkeypatch):+ """The check is config-backed and uncached: a switch to ElevenLabs right after an Edge+ listing must expose tts_voices (a cached False would stick under the new fingerprint)."""+ import os++ import model_tools+ from hermes_constants import get_hermes_home++ monkeypatch.setenv("ELEVENLABS_API_KEY", "el-test-key")+ config_path = get_hermes_home() / "config.yaml"++ def listed(provider: str, stamp: int) -> set:+ config_path.write_text(f"tts:\n provider: {provider}\n")+ os.utime(config_path, (stamp, stamp))+ defs = model_tools.get_tool_definitions(enabled_toolsets=["tts"], quiet_mode=True)+ return {d["function"]["name"] for d in defs}++ assert "tts_voices" not in listed("edge", 1_700_000_000)+ assert "tts_voices" in listed("elevenlabs", 1_700_000_100)+ assert "tts_voices" not in listed("edge", 1_700_000_200)diff --git a/tools/tts_voices_tool.py b/tools/tts_voices_tool.pyindex e277390e582..7a630309185 100644--- a/tools/tts_voices_tool.py+++ b/tools/tts_voices_tool.py@@ -16,7 +16,7 @@ from typing import Any, Optionalimport httpx-from tools.registry import registry, tool_error+from tools.registry import no_cache_check_fn, registry, tool_errorlogger = logging.getLogger(__name__)@@ -29,6 +29,7 @@ _TIMEOUT_SECONDS = 20.0_FILTERS = ("gender", "age", "accent", "language")+@no_cache_check_fn # config-backed and local: a provider switch must show/hide it at oncedef check_tts_voices_requirements() -> bool:"""Exposed only when ElevenLabs is the configured TTS provider and its key resolves."""from tools import tts_tool