Skip to content

Fix: Parsing lang from stt ctor#1028

Merged
toubatbrian merged 5 commits intomainfrom
ac/inference-ctor-parsing
Feb 10, 2026
Merged

Fix: Parsing lang from stt ctor#1028
toubatbrian merged 5 commits intomainfrom
ac/inference-ctor-parsing

Conversation

@adrian-cowham
Copy link
Copy Markdown
Contributor

@adrian-cowham adrian-cowham commented Feb 5, 2026

Summary by CodeRabbit

  • New Features
    • Speech-to-text accepts model identifiers that include a language (e.g., "provider/model:language") and will derive the language automatically.
    • If a separate language is also provided and conflicts, a warning is shown and the explicit language choice is respected.
    • Internal handling updated so selected model and language are applied consistently.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 5, 2026

🦋 Changeset detected

Latest commit: 465b52c

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

This PR includes changesets to release 19 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-xai 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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Parses language from model strings of the form "provider/model:language", computes nextModel and nextLanguage, applies them to STT options, and updates the STT constructor to accept ModelWithLanguage. If an explicit language argument conflicts with the model-embedded language, a warning is logged and the argument value is used.

Changes

Cohort / File(s) Summary
STT Configuration & Constructor
agents/src/inference/stt.ts
Add parsing of provider/model:language into nextModel/nextLanguage; use computed values in STT options; log warning on language conflicts; change constructor parameter type from TModel to ModelWithLanguage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • lukasIO
  • toubatbrian

Poem

🐰 I nibble strings where languages hide,
I split the model and the tongue inside.
If both disagree I'll softly warn,
Then hop along with the chosen form. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is entirely missing; no description was provided by the author despite the template requiring Description, Changes Made, Pre-Review Checklist, Testing, and Additional Notes sections. Add a comprehensive PR description following the template, including what the PR does, specific changes made, confirmation of pre-review checklist items, testing details, and any additional context needed for reviewers.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix: Parsing lang from stt ctor' directly addresses the main change: adding language parsing logic to the STT constructor.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ac/inference-ctor-parsing

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7b6c1d and bb9ad18.

📒 Files selected for processing (1)
  • agents/src/inference/stt.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/agent-core.mdc)

Add SPDX-FileCopyrightText and SPDX-License-Identifier headers to all newly added files with '// SPDX-FileCopyrightText: 2025 LiveKit, Inc.' and '// SPDX-License-Identifier: Apache-2.0'

Files:

  • agents/src/inference/stt.ts
**/*.{ts,tsx}?(test|example|spec)

📄 CodeRabbit inference engine (.cursor/rules/agent-core.mdc)

When testing inference LLM, always use full model names from agents/src/inference/models.ts (e.g., 'openai/gpt-4o-mini' instead of 'gpt-4o-mini')

Files:

  • agents/src/inference/stt.ts
**/*.{ts,tsx}?(test|example)

📄 CodeRabbit inference engine (.cursor/rules/agent-core.mdc)

Initialize logger before using any LLM functionality with initializeLogger({ pretty: true }) from '@livekit/agents'

Files:

  • agents/src/inference/stt.ts
🧠 Learnings (2)
📚 Learning: 2026-01-16T14:33:39.551Z
Learnt from: CR
Repo: livekit/agents-js PR: 0
File: .cursor/rules/agent-core.mdc:0-0
Timestamp: 2026-01-16T14:33:39.551Z
Learning: Applies to **/*.{ts,tsx}?(test|example|spec) : When testing inference LLM, always use full model names from `agents/src/inference/models.ts` (e.g., 'openai/gpt-4o-mini' instead of 'gpt-4o-mini')

Applied to files:

  • agents/src/inference/stt.ts
📚 Learning: 2026-01-16T14:33:39.551Z
Learnt from: CR
Repo: livekit/agents-js PR: 0
File: .cursor/rules/agent-core.mdc:0-0
Timestamp: 2026-01-16T14:33:39.551Z
Learning: Applies to **/*.{ts,tsx}?(test|example) : Initialize logger before using any LLM functionality with `initializeLogger({ pretty: true })` from 'livekit/agents'

Applied to files:

  • agents/src/inference/stt.ts
🧬 Code graph analysis (1)
agents/src/inference/stt.ts (1)
agents/src/inference/index.ts (2)
  • ModelWithLanguage (21-21)
  • STTLanguages (19-19)
🪛 GitHub Actions: Build
agents/src/inference/stt.ts

[error] 178-178: TS2322: Type 'ModelWithLanguage | undefined' is not assignable to type 'TModel | undefined'. Build step: 'tsc --declaration --emitDeclarationOnly && node ../scripts/copyDeclarationOutput.js'

🔇 Additional comments (1)
agents/src/inference/stt.ts (1)

123-132: Constructor signature update looks good.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@adrian-cowham adrian-cowham changed the title parsing lang from stt ctor Fix: Parsing lang from stt ctor Feb 5, 2026
}

// Parse language from model string if provided: "provider/model:language"
let nextModel = 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.

We might want to change the model type to ModelWithLanguage

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
agents/src/inference/stt.ts (1)

158-185: ⚠️ Potential issue | 🔴 Critical

Fix TS2322 by narrowing nextModel to TModel.
The constructor assigns model: nextModel to this.opts (line 178), which expects type TModel | undefined. However, nextModel starts as ModelWithLanguage | undefined, and TypeScript cannot narrow the type through the conditional reassignment. Cast nextModel upfront and parse the original model parameter to ensure proper type narrowing.

🔧 Proposed fix
-    let nextModel = model;
+    let nextModel = model as TModel | undefined;
     let nextLanguage = language;
-    if (typeof nextModel === 'string') {
-      const idx = nextModel.lastIndexOf(':');
+    if (typeof model === 'string') {
+      const idx = model.lastIndexOf(':');
       if (idx !== -1) {
-        const languageFromModel = nextModel.slice(idx + 1) as STTLanguages;
+        const languageFromModel = model.slice(idx + 1) as STTLanguages;
         if (nextLanguage && nextLanguage !== languageFromModel) {
           this.#logger.warn(
             '`language` is provided via both argument and model, using the one from the argument',
             { language: nextLanguage, model: nextModel },
           );
         } else {
           nextLanguage = languageFromModel;
         }
-        nextModel = nextModel.slice(0, idx) as TModel;
+        nextModel = model.slice(0, idx) as TModel;
       }
     }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7b6c1d and bb9ad18.

📒 Files selected for processing (1)
  • agents/src/inference/stt.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/agent-core.mdc)

Add SPDX-FileCopyrightText and SPDX-License-Identifier headers to all newly added files with '// SPDX-FileCopyrightText: 2025 LiveKit, Inc.' and '// SPDX-License-Identifier: Apache-2.0'

Files:

  • agents/src/inference/stt.ts
**/*.{ts,tsx}?(test|example|spec)

📄 CodeRabbit inference engine (.cursor/rules/agent-core.mdc)

When testing inference LLM, always use full model names from agents/src/inference/models.ts (e.g., 'openai/gpt-4o-mini' instead of 'gpt-4o-mini')

Files:

  • agents/src/inference/stt.ts
**/*.{ts,tsx}?(test|example)

📄 CodeRabbit inference engine (.cursor/rules/agent-core.mdc)

Initialize logger before using any LLM functionality with initializeLogger({ pretty: true }) from '@livekit/agents'

Files:

  • agents/src/inference/stt.ts
🧠 Learnings (2)
📚 Learning: 2026-01-16T14:33:39.551Z
Learnt from: CR
Repo: livekit/agents-js PR: 0
File: .cursor/rules/agent-core.mdc:0-0
Timestamp: 2026-01-16T14:33:39.551Z
Learning: Applies to **/*.{ts,tsx}?(test|example|spec) : When testing inference LLM, always use full model names from `agents/src/inference/models.ts` (e.g., 'openai/gpt-4o-mini' instead of 'gpt-4o-mini')

Applied to files:

  • agents/src/inference/stt.ts
📚 Learning: 2026-01-16T14:33:39.551Z
Learnt from: CR
Repo: livekit/agents-js PR: 0
File: .cursor/rules/agent-core.mdc:0-0
Timestamp: 2026-01-16T14:33:39.551Z
Learning: Applies to **/*.{ts,tsx}?(test|example) : Initialize logger before using any LLM functionality with `initializeLogger({ pretty: true })` from 'livekit/agents'

Applied to files:

  • agents/src/inference/stt.ts
🧬 Code graph analysis (1)
agents/src/inference/stt.ts (1)
agents/src/inference/index.ts (2)
  • ModelWithLanguage (21-21)
  • STTLanguages (19-19)
🪛 GitHub Actions: Build
agents/src/inference/stt.ts

[error] 178-178: TS2322: Type 'ModelWithLanguage | undefined' is not assignable to type 'TModel | undefined'. Build step: 'tsc --declaration --emitDeclarationOnly && node ../scripts/copyDeclarationOutput.js'

🔇 Additional comments (1)
agents/src/inference/stt.ts (1)

123-132: Constructor signature update looks good.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@toubatbrian
Copy link
Copy Markdown
Contributor

Hey @adrian-cowham, what's the status of this PR? Are we still plan to merge it?

@adrian-cowham
Copy link
Copy Markdown
Contributor Author

Yeah. It's good to go if you approve.

Copy link
Copy Markdown
Contributor

@toubatbrian toubatbrian left a comment

Choose a reason for hiding this comment

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

Thanks for confirming, could you resolve the build error as well. Once it is resolved, I'll go ahead and merge it

Copy link
Copy Markdown
Contributor

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

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 potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@toubatbrian toubatbrian merged commit 4fb4f99 into main Feb 10, 2026
1 check passed
@toubatbrian toubatbrian deleted the ac/inference-ctor-parsing branch February 10, 2026 22:07
@github-actions github-actions Bot mentioned this pull request Feb 10, 2026
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