Skip to content

fix(livekit): preserve client pause intent across TTS playback - #1

Open
ctaylor86 wants to merge 2 commits into
kortexa-ai:mainfrom
ctaylor86:feat/streaming-tts-adapter
Open

fix(livekit): preserve client pause intent across TTS playback#1
ctaylor86 wants to merge 2 commits into
kortexa-ai:mainfrom
ctaylor86:feat/streaming-tts-adapter

Conversation

@ctaylor86

@ctaylor86 ctaylor86 commented Jul 29, 2026

Copy link
Copy Markdown

Summary

Reworked on current main (a6bd9a5d7a84e54e84894801128f60df8dade3c2) as requested. Reuses the existing shared streaming sink rather than retaining the original parallel streaming implementation.

  • Separate client pause/resume intent from playback echo suppression.
  • Preserve client pause through streaming and whole-file completion/cancellation; resuming during playback cannot disable echo suppression.
  • Clear departed-session pause intent after room teardown, while retaining it across same-session reconnection.
  • Add regression coverage for receive/poll gates, replacement streams, stale ownership, blocked capture cancellation, leave/rejoin, reconnect and whole-file completion/cancellation/decode errors.

Only hermes_livekit/adapter.py and tests/test_streaming_tts.py change. Shared sink, resampler, source ownership and cancellation safeguards remain unchanged.

Verification

Candidate: f39794693ed45ef4a17ce6ae725a12c5f6792fe0.

  • Focused pause regressions: 18 passed.
  • Full suite: 524 passed, 5 failed, 4 skipped.
  • Unmodified plugin base with the same host dependency/environment: 506 passed, the same 5 failed, 4 skipped.
  • Initial pause regressions reproduced failures before the change; the leave/rejoin regression separately reproduced the stale pause bug before its correction.
  • Independent final review found no new correctness blockers.
  • Compilation and git diff --check passed. No hardware/provider canaries were run.

Tests use isolated Python 3.11 with plugin dev dependencies and unmodified editable Hermes main d4d4ecfae0c135b7bb52ff4f782ffef17bbc90c7. Plain PyPI installation could not resolve the declared hermes-agent>=0.20.0 dependency in the available index.

Existing integration failures and limits

The five unchanged failures are quiet-prefix fallback (both transports), incomplete-first-sample fallback (both transports), and long-reply finalizer draining. This is not a fully green host/plugin integration qualification.

The existing shared sink still awaits output_started() under its lifecycle lock. This narrow pause-intent revision preserves that upstream implementation and does not claim to resolve slow speaking-start publication blocking abort. Capture-frame backpressure cancellation is tested separately.

@kortexa-ai-bot

kortexa-ai-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

External contribution triage

This PR separates explicit client pause state (`_client_paused`) from TTS echo-suppression state (`_paused`), applies both gates to audio receipt and silence polling, and clears client pause intent when a room session is torn down. The supplied tests cover streaming and whole-file TTS completion, interruption, replacement, cancellation, reconnect, and leave/rejoin behavior. No concrete correctness or security regression is evident in the supplied diff. The reported full suite is not green, but the five failures are stated to reproduce on the unmodified base.

Reviewed commit: f39794693ed45ef4a17ce6ae725a12c5f6792fe0.

Code coverage: 2 of 2 changed files; static review only. Contributed code was not executed.

No actionable code findings were identified in the reviewed changes. This is not an approval or a guarantee that the changes are correct.

Coverage limits: Full-file context exceeded the review budget: hermes_livekit/adapter.py; Full-file context exceeded the review budget: tests/test_streaming_tts.py; Credential-like source strings were redacted before cloud analysis.

A maintainer decides next steps. This automation does not fix code, close items, approve, or merge changes.

@kortexa-ai-bot kortexa-ai-bot Bot added triage:enhancement Kortexa external intake: enhancement. triage:external Kortexa external intake: external. triage:needs-maintainer Kortexa external intake: needs-maintainer. labels Sep 8, 2026
@francip

francip commented Sep 8, 2026

Copy link
Copy Markdown
Member

@ctaylor86 sorry about the slow response, this PR got lost in all the noise on Github. I've updated my external contributions management system, so hopefully won't drop things in the cracks anymore.

@kortexa-ai-bot

kortexa-ai-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

Thanks for this contribution. Since it was opened, main has gained shared streaming-TTS support for LiveKit and Direct WebRTC, so much of this implementation now overlaps.

Could you update the PR to build on the existing shared sink, focusing on preserving client pause/resume intent and adding regression tests for that behavior? Please retain the current source-ownership and cancellation safeguards.

The original implementation also has two ownership issues: stale finish cleanup can clear a replacement reply, and declining an overlapping stream permits whole-file fallback to compete for the same source.

Adapt the residual client pause/resume behavior from PR kortexa-ai#1, commit 2e064ab, onto the existing shared streaming sink. Keep playback ownership and cancellation unchanged.
@ctaylor86
ctaylor86 force-pushed the feat/streaming-tts-adapter branch from 2e064ab to f397946 Compare September 8, 2026 11:33
@ctaylor86 ctaylor86 changed the title feat(tts): stream PCM replies through LiveKit fix(livekit): preserve client pause intent across TTS playback Sep 8, 2026
@ctaylor86

Copy link
Copy Markdown
Author

Thanks for the direction. Reworked this on current main using the existing shared sink, limited to client pause/resume intent and regression tests. The new head is f397946. All 18 pause regressions pass, including full leave/rejoin and same-session reconnect; independent review found no new blockers. The full suite has 524 passes and the same five host-integration failures seen on the unmodified base (detailed in the updated description). Source ownership and cancellation safeguards are unchanged. The existing shared-sink speaking-start publication lock remains a separate limitation, not something this patch claims to fix.

@kortexa-ai-bot kortexa-ai-bot Bot added triage:bug Kortexa external intake: bug. and removed triage:enhancement Kortexa external intake: enhancement. labels Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage:bug Kortexa external intake: bug. triage:external Kortexa external intake: external. triage:needs-maintainer Kortexa external intake: needs-maintainer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants