Skip to content

fix(deepgram): forward enable_diarization and tags to open streams - #7821

Closed
Atharvsinh-codez wants to merge 1 commit into
livekit:mainfrom
Atharvsinh-codez:fix/deepgram-stt-forward-diarization-tags
Closed

Atharvsinh-codez wants to merge 1 commit into
livekit:mainfrom
Atharvsinh-codez:fix/deepgram-stt-forward-diarization-tags

Conversation

@Atharvsinh-codez

Copy link
Copy Markdown

Summary

deepgram.STT.update_options() saves enable_diarization and tags on the STT, but the call that updates the open streams leaves both out. Each stream keeps its own copy of the options, so it reconnects with the old values. That has two effects:

  • stt.update_options(enable_diarization=True) during a session reconnects the stream without diarize=true. No speaker IDs come back, and nothing reports an error.
  • new tags never reach Deepgram for the open stream.

SpeechStream.update_options() already accepts both parameters, and stt_v2 already forwards tags. Only these two arguments were missing from the forwarding call.

Test plan

  • added test_stt_update_options_reaches_open_streams_diarization_and_tags. It opens a stream, calls STT.update_options(enable_diarization=True, tags=["prod"]), and checks the URL of the reconnected socket. It fails on main (no diarize in the query) and passes with this change.
  • uv run pytest tests/test_plugin_deepgram_stt.py --plugin deepgram: 42 passed.
  • ruff check, ruff format, and mypy (livekit.plugins.deepgram) are clean.

STT.update_options() stored enable_diarization and tags on the STT but
left them out of the call that updates the open streams. Each stream keeps
its own copy of the options, so it reconnected with the old values: turning
diarization on mid-session never sent diarize=true, and new tags never
reached Deepgram.
@Atharvsinh-codez
Atharvsinh-codez requested a review from a team as a code owner October 14, 2026 15:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T15:18:45.695519Z 1d7372f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@CLAassistant

CLAassistant commented Oct 14, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@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 found 1 potential issue.

Devin Review

sample_rate=sample_rate,
no_delay=no_delay,
endpointing_ms=endpointing_ms,
enable_diarization=enable_diarization,

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.

🟡 Enabled diarization remains unavailable to adapters

After update_options(enable_diarization=True), open streams emit speaker IDs but capabilities.diarization stays false. MultiSpeakerAdapter rejects the STT even though diarization is active.

Learn more

The constructor initializes capabilities.diarization from the initial option in STT.init. The newly forwarded update changes the configuration of open sockets without updating that capability. MultiSpeakerAdapter gates construction on the capability, so an STT can produce speaker IDs while the adapter refuses it.

Example: Create STT(api_key="test-key"), open a stream, then call update_options(enable_diarization=True). The next Deepgram socket requests diarize=true, but MultiSpeakerAdapter(stt=instance) raises ValueError.

Recommended fix: Synchronize self._capabilities.diarization with an explicitly supplied enable_diarization in STT.update_options and cover both enabling and disabling with a test. Consider how existing wrappers cache the capabilities at construction.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@Atharvsinh-codez

Copy link
Copy Markdown
Author

Folded into #7828 together with the other two STT fixes and a fix for the flaky unit-tests failure. Closing this one.

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