Skip to content

Expose Cartesia STT turn detection options - #2156

Closed
rosetta-livekit-bot[bot] wants to merge 1 commit into
mainfrom
marble-fusible-elixirs
Closed

Expose Cartesia STT turn detection options#2156
rosetta-livekit-bot[bot] wants to merge 1 commit into
mainfrom
marble-fusible-elixirs

Conversation

@rosetta-livekit-bot

@rosetta-livekit-bot rosetta-livekit-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Exposes Cartesia ink-2 STT turn-detection thresholds and keyterm options on STTOptions.
  • Sends the new options as /stt/turns/websocket query parameters, preserving repeated keyterm values.
  • Rejects turn-detection-only options for legacy ink-whisper STT models.
  • Adds a Cartesia changeset and API report metadata for the new public API.
Source diff coverage
Source file from livekit/agents#6594 Target coverage
livekit-plugins/livekit-plugins-cartesia/livekit/plugins/cartesia/_recognize_streams/auto_finalize_recognize_stream.py Adapted to plugins/cartesia/src/stt.ts. The JS plugin keeps the turn-detecting websocket stream in the main STT file rather than a separate recognize-stream module, so the constructor/storage changes map to STTOptions and SpeechStream, and websocket query serialization maps to SpeechStream.#getCartesiaUrl().
livekit-plugins/livekit-plugins-cartesia/livekit/plugins/cartesia/stt.py Ported to plugins/cartesia/src/stt.ts. Added public STT options, legacy-model validation, option storage/updates, and propagation to the turn-detecting websocket stream.
Tests Not applicable. Source PR #6594 does not add or modify tests, so no target tests were added beyond running the existing Cartesia package tests.

Testing

  • pnpm test plugins/cartesia
  • pnpm --filter @livekit/agents-plugin-cartesia build
  • pnpm --filter @livekit/agents-plugin-cartesia lint
  • pnpm --filter @livekit/agents-plugin-cartesia api:check
  • pnpm build
  • pnpm lint (completed successfully; existing warnings are emitted in unrelated packages)

Ported from livekit/agents#6594

Original PR description

Sibling of #6587 (same pattern for xAI STT): exposes the turn-detection tuning parameters documented for Cartesia's /stt/turns/websocket (https://docs.cartesia.ai/api-reference/stt/turns/websocket) on cartesia.STT:

  • turn_start_threshold (0.5–0.9, default 0.8) — likelihood above which a turn starts
  • turn_eager_end_threshold (0.3–0.6, default 0.4) — likelihood below which turn.eager_end fires
  • turn_end_threshold (0.05–0.5, default 0.2) — likelihood below which the turn ends
  • turn_end_timeout_ms (640–11200, default 5600) — silence backstop for ending a turn
  • keyterm (list, up to 100 terms / 1200 chars) — recall biasing; sent as repeated query params, so the turns-websocket params dict became a list of pairs

These are the primary tuning levers when running ink-2 with turn_detection="stt" in an AgentSession — today the plugin connects to the turns endpoint with no way to adjust them. All five are NotGivenOr and omitted when unset, so the default connection sends the identical query string as before. Passing any of them with a non-turn-detecting model (ink-whisper → the legacy endpoint) raises ValueError, mirroring the model-gated params in the AssemblyAI plugin.

Live-verified against wss://api.cartesia.ai/stt/turns/websocket (real key, today):

  • in-range values (e.g. turn_start_threshold=0.85, repeated keyterm) → {"type":"connected", ...}
  • out-of-range (turn_start_threshold=2.0) → error frame "turn_start_threshold must be between 0.5 and 0.9." + close — so the server parses and validates exactly these param names (unknown params are silently ignored, which is why the client-side ValueError guard is worth having)

Verified with ruff check / ruff format.

🤖 Generated with Claude Code

@rosetta-livekit-bot
rosetta-livekit-bot Bot requested a review from a team as a code owner July 29, 2026 05:23
@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d6718ab

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

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

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: No Issues Found

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

Open in Devin Review

@u9g

u9g commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

done in #2173

@u9g u9g closed this Jul 30, 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.

1 participant