Skip to content

fix(tts): stop the hourly cache sweep from deleting TTS voice memos - #100120

Open
Sahilvishnaliya wants to merge 1 commit into
NousResearch:mainfrom
Sahilvishnaliya:fix/tts-memo-cache-sweep
Open

Sahilvishnaliya wants to merge 1 commit into
NousResearch:mainfrom
Sahilvishnaliya:fix/tts-memo-cache-sweep

Conversation

@Sahilvishnaliya

Copy link
Copy Markdown
Contributor

Fixes #100075

Problem

text_to_speech documented ~/voice-memos/ as the CLI output location (docstring tts_tool.py:3514 + tool schema :4500), but every surface writes to the gateway audio cache — the same directory cleanup_audio_cache sweeps once per hour with a 24h max age (gateway/run.py housekeeping → base.py:1133). A generated voice memo was silently deleted ~24h later while the tool contract promised persistence; the failure was invisible until the user went looking for the file. Contract and behavior were exact opposites.

Fix (maintainer's option 2 from the issue)

(a) Make memos survive the sweep: _cleanup_cache_dir gains sticky_prefixes; cleanup_audio_cache passes ("tts_",) — TTS-generated files are named tts_{timestamp}.{fmt} by tts_tool.py:3250-3256, so the prefix cleanly separates user artifacts from inbound platform voice notes (which remain swept as before).

(b) Fix the contract: docstring and tool-schema description now state the real default output dir (~/.hermes/cache/audio) and the sweep exemption, instead of the fictional ~/voice-memos/.

Verification

tests/gateway/test_audio_cache.py: 7/7 pass, including the new regression test — a tts_* file backdated 48h (past the 24h cutoff) survives the sweep while the existing old-file removal tests stay green.

text_to_speech documented ~/voice-memos/ as the CLI output location, but every surface writes to the gateway audio cache - the same directory cleanup_audio_cache sweeps once per hour with a 24h max age. A generated voice memo was silently deleted ~24h later while the tool contract promised persistence; the failure was invisible until the user went looking for the file. Contract and behavior were opposites (NousResearch#100075).

Fix, maintainer's option 2: (a) the shared _cleanup_cache_dir now takes sticky_prefixes and cleanup_audio_cache excludes TTS-produced tts_* files from the sweep - memos persist; (b) docstring and tool-schema description now state the real default output dir and the sweep exemption instead of the fictional ~/voice-memos/. Fixes NousResearch#100075.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery tool/tts Text-to-speech and transcription sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Sep 1, 2026
@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference; please use your judgment.

Clean fix for #100075: _cleanup_cache_dir gains a sticky_prefixes tuple parameter (gateway/platforms/base.py:991), and cleanup_audio_cache passes ("tts_",) so TTS-generated voice memos sharing the audio cache with inbound voice notes survive the hourly sweep regardless of age. str.startswith accepts the tuple form directly, and the refactored loop preserves the original is_file + mtime semantics while adding the sticky check before the unlink. The tool schema/docstring updates keep the CLI and messaging descriptions consistent with the new default-output behavior, and the regression test reproduces the 48h-old memo case.

Non-blocking: exempt files now accumulate in ~/.hermes/cache/audio without any cap (only user deletion reclaims space) — worth confirming that's acceptable for long-running gateways, or consider a separate memos directory with its own retention story.

Non-blocking: the test asserts removed == 0 after a full sweep of the shared audio cache dir; if any unrelated stale file exists in that dir (real usage or earlier tests), the assertion is flaky. Scoping the test to a dedicated temp cache dir would make it deterministic.

Verdict: LGTM

@kvnloo

kvnloo commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Exact-head KEEP on #100120 head e9613f3.

KEEP stopping cleanup_audio_cache from deleting TTS outputs the tool contract documents as durable voice memos (#100075). KEEP writing CLI/tool TTS outside the 24h gateway audio cache (or otherwise exempting memo paths). KEEP tests/gateway/test_audio_cache.py + tts_tool docstring/schema alignment.

CHECK: gateway ephemeral auto-TTS cache still sweeps. CHECK: documented ~/voice-memos/ (or chosen durable path) survives >24h. Author Sahilvishnaliya not kvnloo. No competing PR.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades tool/tts Text-to-speech and transcription type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

text_to_speech documents ~/voice-memos/ as CLI output dir but writes to the gateway audio cache (swept after 24h)

4 participants