Skip to content

fix(deepgram): validate updated model with stored language#1755

Open
rosetta-livekit-bot[bot] wants to merge 1 commit into
1.5.0from
rumba-anteed-spinier
Open

fix(deepgram): validate updated model with stored language#1755
rosetta-livekit-bot[bot] wants to merge 1 commit into
1.5.0from
rumba-anteed-spinier

Conversation

@rosetta-livekit-bot

@rosetta-livekit-bot rosetta-livekit-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Ports livekit/agents#6041 to agents-js.\n\nSummary:\n- Reuses Deepgram STT model validation from construction when updateOptions changes the model.\n- Uses an explicitly provided language for validation, otherwise falls back to the stored language.\n- Adds a patch changeset for the Deepgram plugin.\n\nTests:\n- pnpm exec prettier --write "plugins/deepgram/src/stt.ts"\n- pnpm --filter @livekit/agents-plugin-deepgram... build\n\nNo tests added, matching the requested port constraint.


Ported from livekit/agents#6041

Original PR description

`STT.update_options` and `SpeechStream.update_options` both call `_validate_model(model, language)` using the caller's `language` parameter. When only the model is changed, `language` is `NOT_GIVEN`, so `_validate_model` skips its English-only model check entirely — allowing an incompatible model/language pair to be stored silently.

For example, after `STT(language="fr")`, calling `update_options(model="nova-2-meeting")` would accept `nova-2-meeting` (English-only) with no warning, instead of falling back to `nova-2-general`.

Fix: pass `self._opts.language or NOT_GIVEN` when the caller omits `language`, so the stored language is used for validation.

Fixes #6047

Test plan

```
uv run pytest tests/test_plugin_deepgram_stt.py --plugin deepgram -v
```

@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 893b698

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 34 packages
Name Type
@livekit/agents-plugin-deepgram Patch
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch
@livekit/agents-plugins-test Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@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 2 potential issues.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment on lines +123 to +124
const model =
opts.model !== undefined ? this.#validateModel(opts.model, language) : this.#opts.model;

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.

🟡 Model validation skipped when only language is updated via updateOptions

In updateOptions, the model is only validated when opts.model !== undefined. If a caller changes only the language (e.g., updateOptions({ language: 'fr' })) while the current model is an English-only one like 'nova-2-meeting', the validation is skipped and the incompatible model/language combination persists. This defeats the purpose of the PR, which is to ensure model validation happens in updateOptions.

For example: a user creates new STT({ model: 'nova-2-meeting', language: 'en-US' }) (valid), then calls updateOptions({ language: 'fr' }). The model variable at line 124 takes the this.#opts.model path (no validation), resulting in 'nova-2-meeting' being used with French — exactly the case #validateModel is supposed to catch.

Suggested change
const model =
opts.model !== undefined ? this.#validateModel(opts.model, language) : this.#opts.model;
const model = this.#validateModel(opts.model ?? this.#opts.model, language);
Open in Devin Review

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

Comment on lines +120 to +131
updateOptions(opts: Partial<STTOptions>) {
const language =
opts.language !== undefined ? normalizeLanguage(opts.language) : this.#opts.language;
const model =
opts.model !== undefined ? this.#validateModel(opts.model, language) : this.#opts.model;

this.#opts = {
...this.#opts,
...opts,
language,
model,
};

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.

🚩 detectLanguage flag not handled in updateOptions

The constructor at line 108-109 sets this.#opts.language = undefined when detectLanguage is true, and skips model validation. However, updateOptions does not mirror this behavior — if a caller passes updateOptions({ detectLanguage: true }), the language won't be cleared and the model validation still runs against the stale language. This is a pre-existing issue (the old code also didn't handle it), and may be intentionally left as a caller responsibility, but it creates an inconsistency between construction-time and update-time semantics.

Open in Devin Review

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

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.

0 participants