feat(deepgram): add redact STT option#1443
Conversation
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 detectedLatest commit: ef15360 The changes in this PR will be included in the next version bump. This PR includes changesets to release 31 packages
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 |
|
|
There was a problem hiding this comment.
💡 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".
| ...(this.#opts.redact && | ||
| (Array.isArray(this.#opts.redact) ? this.#opts.redact.length : true) | ||
| ? { redact: this.#opts.redact } |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
Ports the new
redactparameter for the Deepgram STT plugin from the Pythonlivekit/agentsrepo intoagents-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
redactfield toSTTOptions(Deepgram V1 streaming STT) that lets callers redact sensitive information from transcripts.string | string[]"pci","numbers","ssn","true"(redact all). See https://developers.deepgram.com/docs/redaction for details.[](no redaction).redact=<value>on the/v1/listenWebSocket query string. Multiple values are sent as repeated query params (matching howkeyterm/keywordsare encoded).Usage
Implementation notes / parity differences
The Python upstream patch updates
STTOptions, theSTT.__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:SpeechStream); there is no_recognize_implREST batch path (STT._recognizethrows'Recognize is not supported on Deepgram STT'). So only the WebSocket query-string construction needed updating, vs. the two sites in Python.update_optionssignature. Python addsredactas a separate kwarg in twoupdate_optionsoverloads. JS already has a genericupdateOptions(opts: Partial<STTOptions>)that spreads the new options, so no new parameter wiring was needed — adding the field toSTTOptionsis sufficient.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 whenredactis a non-empty string or non-empty array. This matches the Python truthiness check (empty list/empty string are both omitted).stt.py(V1 endpoint), notstt_v2.py. The JS port likewise leavesstt_v2.tsuntouched. If/when upstream addsredactto V2, that should be a follow-up port.STTOptionsinterface in JS does not document individual fields with JSDoc (unlikeSTTv2Options). The port preserves that style; the option is documented in this PR description and via the upstream Deepgram link.Out of scope
stt.test.tsdoes not exercise URL parameter construction, and the upstream PR did not add tests either.Test plan
pnpm buildsucceedspnpm lintproduces no new errors inplugins/deepgram/src/stt.tsSTT({ redact: 'pci' })and verify theredactquery parameter appears on the Deepgram/v1/listenWebSocket URLSTT()(default) and verify noredactparameter is sentSTT({ redact: ['pci', 'numbers'] })and verify two repeatedredactquery paramsChangeset
A patch-level changeset is included for
@livekit/agents-plugin-deepgram.Generated by Claude Code