Skip to content

feat(deepgram): add redact STT option#1443

Open
toubatbrian wants to merge 1 commit intomainfrom
claude/quirky-galileo-Di566
Open

feat(deepgram): add redact STT option#1443
toubatbrian wants to merge 1 commit intomainfrom
claude/quirky-galileo-Di566

Conversation

@toubatbrian
Copy link
Copy Markdown
Contributor

Summary

Ports the new redact parameter for the Deepgram STT plugin from the Python livekit/agents repo into agents-js.

Upstream PR: livekit/agents#5692 (closes upstream issue livekit/agents#5683).

This is an automated Claude Code Routine port created by @toubatbrian. Right now it is in experimentation stage.

cc @toubatbrian @livekit/agent-devs — please review.

Ported feature

Adds an optional redact field to STTOptions (Deepgram V1 streaming STT) that lets callers redact sensitive information from transcripts.

  • Type: string | string[]
  • Supported values (per Deepgram): "pci", "numbers", "ssn", "true" (redact all). See https://developers.deepgram.com/docs/redaction for details.
  • Default: [] (no redaction).
  • When set to a non-empty value, the parameter is forwarded to Deepgram as redact=<value> on the /v1/listen WebSocket query string. Multiple values are sent as repeated query params (matching how keyterm/keywords are encoded).
  • When empty (default), the parameter is omitted from the request entirely, preserving existing behavior.

Usage

import { STT } from '@livekit/agents-plugin-deepgram';

const stt = new STT({
  redact: ['pci', 'numbers'], // or 'true' to redact everything
});

Implementation notes / parity differences

The Python upstream patch updates STTOptions, the STT.__init__ signature, update_options, and both _recognize_impl (REST) and _connect_ws (WebSocket) call sites. The JS plugin is structured differently, so the port collapses naturally:

  1. Single code path. The JS Deepgram plugin only exposes a streaming WebSocket implementation (SpeechStream); there is no _recognize_impl REST batch path (STT._recognize throws 'Recognize is not supported on Deepgram STT'). So only the WebSocket query-string construction needed updating, vs. the two sites in Python.
  2. update_options signature. Python adds redact as a separate kwarg in two update_options overloads. JS already has a generic updateOptions(opts: Partial<STTOptions>) that spreads the new options, so no new parameter wiring was needed — adding the field to STTOptions is sufficient.
  3. Conditional emission. Python uses if config.redact: to omit the field when falsy. The JS port mirrors that with a conditional spread when constructing the params object: only included when redact is a non-empty string or non-empty array. This matches the Python truthiness check (empty list/empty string are both omitted).
  4. STT V2 (Flux) not modified. The Python PR only touched stt.py (V1 endpoint), not stt_v2.py. The JS port likewise leaves stt_v2.ts untouched. If/when upstream adds redact to V2, that should be a follow-up port.
  5. No JSDoc on the new field. The existing STTOptions interface in JS does not document individual fields with JSDoc (unlike STTv2Options). The port preserves that style; the option is documented in this PR description and via the upstream Deepgram link.

Out of scope

  • No tests added — the existing stt.test.ts does not exercise URL parameter construction, and the upstream PR did not add tests either.

Test plan

  • pnpm build succeeds
  • pnpm lint produces no new errors in plugins/deepgram/src/stt.ts
  • Manual: instantiate STT({ redact: 'pci' }) and verify the redact query parameter appears on the Deepgram /v1/listen WebSocket URL
  • Manual: instantiate STT() (default) and verify no redact parameter is sent
  • Manual: instantiate STT({ redact: ['pci', 'numbers'] }) and verify two repeated redact query params

Changeset

A patch-level changeset is included for @livekit/agents-plugin-deepgram.


Generated by Claude Code

Ports livekit/agents#5692. Adds a `redact` option to the Deepgram STT
plugin that lets callers redact sensitive information (PCI, numbers,
SSN, etc.) from transcripts. Accepts a single string or list of strings
matching Deepgram's redaction values, and is only sent to the API when
non-empty.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 8, 2026

🦋 Changeset detected

Latest commit: ef15360

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

This PR includes changesets to release 31 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-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-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

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef15360a59

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +199 to +201
...(this.#opts.redact &&
(Array.isArray(this.#opts.redact) ? this.#opts.redact.length : true)
? { redact: this.#opts.redact }
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Disable no_delay when redaction is requested

For streams that set redact but do not also override noDelay, this new branch enables redaction while the request still sends the existing default no_delay=true a few lines above. Deepgram's redaction docs explicitly recommend no_delay=false or omitting it for streaming redaction, and warn that no_delay=true prioritizes latency at the risk of redaction performance; callers enabling this option for sensitive transcripts would not expect the default configuration to make redaction less reliable. Consider forcing/omitting no_delay when redact is non-empty, unless the caller explicitly opts into noDelay: true.

Useful? React with 👍 / 👎.

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 1 additional finding.

Open in Devin Review

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.

3 participants