Skip to content

fix(sarvam): keep idle STTRealtime streams open - #8383

Merged
tinalenguyen merged 3 commits into
livekit:mainfrom
neil-sarvam:sarvam/realtime-keepalive
Nov 18, 2026
Merged

tinalenguyen merged 3 commits into
livekit:mainfrom
neil-sarvam:sarvam/realtime-keepalive

Conversation

@neil-sarvam

@neil-sarvam neil-sarvam commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Split out of #8329 so that each change gets its own PR.

Problem

Sarvam closes a realtime stream after 60 s with no audio (inactivity_timeout, 408). Pings don't reset that timer, and STTRealtime never reconnects (a new connection would be a new session). So muted or gated input ends transcription for the rest of the call.

Fix

  • A keepalive task sends 50 ms of silence after 30 s with no audio sent.
  • The silence advances the audio position and is metered like any other audio.

Testing

  • New tests: silence goes out after the idle interval, and nothing goes out while audio flows.
  • Results: all Sarvam tests pass, and ruff and mypy are clean.
  • Live: I sent speech, then no audio for 75 s, then speech again.
    • With the keepalive, silence went out at 30 s and 60 s, and the second utterance was transcribed.
    • With the keepalive turned off, the stream failed at 60 s with inactivity_timeout (408).

🤖 Generated with Claude Code

Sarvam closes a realtime stream after 60 s with no audio (inactivity_timeout,
408). Pings don't reset it and the stream never reconnects, so muted or gated
input ended transcription for the rest of the call. A keepalive task now sends
50 ms of silence after 30 s with no audio sent; the silence advances the audio
position and is metered like any other audio.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@neil-sarvam
neil-sarvam marked this pull request as ready for review November 5, 2026 10:52
@neil-sarvam
neil-sarvam requested a review from a team as a code owner November 5, 2026 10:52

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@tinalenguyen tinalenguyen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, thanks for the PR! left a few comments, mainly about how the silence interacts with manual endpointing

_process_audio now wakes up after KEEPALIVE_INTERVAL_S without input and sends the
silence itself, so it stays the only audio writer on the socket. Checked live that in
manual endpointing Sarvam accepts the silence between utterances without opening one.
The keepalive tests run on virtual time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@tinalenguyen tinalenguyen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for iterating! left a few small comments, otherwise lgtm

…ive silence

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tinalenguyen
tinalenguyen merged commit 7d4c41a into livekit:main Nov 18, 2026
17 checks passed
neil-sarvam added a commit to neil-sarvam/agents that referenced this pull request Nov 19, 2026
Keep the realtime keyterm tests alongside livekit#8383's keepalive tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants