hermes-agent/tools
kshitij 7b006ea6e8 feat(stt): idle unload for local whisper model
The local faster-whisper model singleton (_local_model) is loaded once
and never released — the 'base' model holds ~370 MB of RAM/VRAM for
the entire lifetime of the process, even when no voice messages arrive
for hours or days. On long-running gateway processes (especially with
local LLMs competing for the same GPU) this is wasteful.

Add a config-driven idle unload: after stt.local.unload_after_idle_seconds
(default 0 = never) of no transcription activity, a lightweight daemon
thread sets _local_model = None so the Python GC can reclaim the
ctranslate2 objects. The next voice message reloads the model
transparently (the existing lazy-load path handles it).

The watcher:
  - Checks every 30s whether idle time exceeds the configured threshold
  - Acquires _local_model_lock before unloading (prevents races with
    concurrent transcriptions that are mid-load)
  - Exits immediately if the model is already None (unloaded by another
    path, e.g. the CUDA fallback eviction)
  - Is restarted by each transcription with the current config value,
    so changing stt.local.unload_after_idle_seconds in config.yaml takes
    effect on the next voice message without a process restart

Default is 0 (never unload) — zero behavior change for existing users.
Recommended value for gateway processes: 300 (5 minutes).

15 tests: config resolution (garbage/negative/None fallbacks), unload
safety (already-None, lock acquisition), touch timestamp, watcher
lifecycle (unload after timeout, no unload within timeout, exits when
model already None, stopped on new start). Existing STT test suite
unchanged.
2026-08-07 19:26:12 +05:30
..
computer_use
…
environments
…
neutts_samples
…
wakewords
…
__init__.py
…
ansi_strip.py
…
approval.py refactor: fold /simplify-code findings 2026-08-06 17:03:10 +05:30
async_delegation.py
…
audio_container.py
…
binary_extensions.py
…
blueprints.py fix(cron): surface initial scheduler registration failures 2026-08-07 17:45:06 +05:30
browser_camofox.py
…
browser_camofox_state.py
…
browser_cdp_tool.py
…
browser_dialog_tool.py
…
browser_supervisor.py
…
browser_tool.py
…
budget_config.py
…
checkpoint_manager.py
…
clarify_gateway.py
…
clarify_tool.py
…
close_terminal_tool.py fix(agent): the desktop's tools reach it on remote and cloud backends too 2026-08-06 19:35:47 -06:00
code_execution_tool.py fix: preserve session history when a turn crashes 2026-08-06 23:08:23 -05:00
computer_use_tool.py
…
credential_files.py
…
cronjob_tools.py refactor(cron): polish registration partial-failure surfaces 2026-08-07 17:45:06 +05:30
daemon_pool.py
…
debug_helpers.py
…
delegate_tool.py fix(delegation): bind steering to session generation 2026-08-06 09:40:27 -07:00
delegation_live_log.py
…
desktop_ui.py
…
discord_tool.py
…
env_passthrough.py
…
env_probe.py
…
fal_common.py
…
feishu_doc_tool.py
…
feishu_drive_tool.py
…
file_operations.py fix(file): align grep fallback regex behavior 2026-08-06 05:31:17 +05:30
file_state.py
…
file_tools.py fix(read_file): stop promising anydoc conversion in the tool schema 2026-08-05 22:03:47 -07:00
flux3_video_tool.py
…
focus_pane_tool.py fix(agent): the desktop's tools reach it on remote and cloud backends too 2026-08-06 19:35:47 -06:00
fuzzy_match.py
…
homeassistant_tool.py
…
hook_output_spill.py
…
image_generation_tool.py
…
image_source.py
…
interrupt.py
…
kanban_tools.py fix(cron): don't let a cron job inherit a kanban worker's dispatcher identity 2026-08-06 03:16:26 +05:30
lazy_deps.py refactor: derive teams install hint via feature_install_command(venv_pip=True) 2026-08-07 13:28:43 +05:30
managed_tool_gateway.py
…
mcp_dashboard_oauth.py
…
mcp_oauth.py
…
mcp_oauth_manager.py
…
mcp_schema_cache.py
…
mcp_stdio_watchdog.py
…
mcp_tool.py
…
memory_tool.py
…
microsoft_graph_auth.py
…
microsoft_graph_client.py
…
neutts_synth.py
…
open_preview_tool.py fix(agent): the desktop's tools reach it on remote and cloud backends too 2026-08-06 19:35:47 -06:00
openrouter_client.py
…
osv_check.py
…
patch_parser.py refactor(file-ops): fold simplify-pass findings 2026-08-04 14:34:24 +05:30
path_security.py
…
process_registry.py fix(secrets): redact command in process checkpoint file (#77484) 2026-08-07 17:01:23 +05:30
project_tools.py
…
react_to_message_tool.py fix(agent): the desktop's tools reach it on remote and cloud backends too 2026-08-06 19:35:47 -06:00
read_extract.py fix(read_extract): cap anydoc input size before conversion 2026-08-05 22:02:42 -07:00
read_preview_tool.py fix(agent): the desktop's tools reach it on remote and cloud backends too 2026-08-06 19:35:47 -06:00
read_terminal_tool.py fix(agent): the desktop's tools reach it on remote and cloud backends too 2026-08-06 19:35:47 -06:00
registry.py
…
schema_sanitizer.py
…
send_message_tool.py
…
session_search_tool.py
…
skill_manager_tool.py
…
skill_provenance.py
…
skill_usage.py
…
skills_ast_audit.py
…
skills_guard.py
…
skills_hub.py
…
skills_sync.py
…
skills_sync_client.py
…
skills_tool.py
…
slash_confirm.py
…
terminal_hints.py
…
terminal_tool.py fix: close simplify-pass findings — scheduler sibling site + home-unresolvable totality 2026-08-06 17:36:40 +05:30
thread_context.py
…
threat_patterns.py
…
tirith_security.py
…
todo_tool.py
…
tool_backend_helpers.py
…
tool_output_limits.py
…
tool_result_storage.py
…
tool_search.py
…
transcription_tools.py feat(stt): idle unload for local whisper model 2026-08-07 19:26:12 +05:30
tts_streaming.py
…
tts_text_normalize.py
…
tts_tool.py
…
url_safety.py
…
video_generation_tool.py
…
vision_tools.py fix(vision): stream image and video downloads with chunk-by-chunk size cap 2026-08-07 18:50:39 +05:30
voice_mode.py fix(voice): early-exit sliding window on match, clear barge phase in finally, fix test helper 2026-08-07 14:38:02 +05:30
wake_word.py fix(wake): auto capture keeps the backend mic when one exists 2026-08-05 10:06:49 -06:00
web_tools.py
…
website_policy.py
…
working_diff.py
…
write_approval.py
…
x_search_tool.py
…
xai_http.py
…
xai_video_tools.py
…
yuanbao_tools.py
…