Skip to content

Move frame processor url/token/stream info to client sdk#1881

Draft
1egoman wants to merge 1 commit into
mainfrom
move-frame-processor-metadata-to-client-sdk
Draft

Move frame processor url/token/stream info to client sdk#1881
1egoman wants to merge 1 commit into
mainfrom
move-frame-processor-metadata-to-client-sdk

Conversation

@1egoman

@1egoman 1egoman commented Jun 25, 2026

Copy link
Copy Markdown

Description

Ports livekit/agents#5867 to node. For more details about this change, read the pull request body / comments there.

TODO

Pre-Review Checklist

  • Build passes: All builds (lint, typecheck, tests) pass locally
  • AI-generated code reviewed: Removed unnecessary comments and ensured code quality
  • Changes explained: All changes are properly documented and justified above
  • Scope appropriate: All changes relate to the PR title, or explanations provided for why they're included
  • Video demo: A small video demo showing changes works as expected and did not break any existing functionality using Agent Playground (if applicable)

Testing

  • Automated tests added/updated (if applicable)
  • All tests pass
  • Make sure both restaurant_agent.ts and realtime_agent.ts work properly (for major changes)

Additional Notes


Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.

@changeset-bot

changeset-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d9d734e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@1egoman 1egoman changed the title Port of https://github.com/livekit/agents/pull/5867 to node Move frame processor url/token/stream info to client sdk Jun 25, 2026
@1egoman 1egoman marked this pull request as draft June 25, 2026 15:49

@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.

Open in Devin Review

Comment on lines 159 to 169
private createStream(track: RemoteTrack): ReadableStream<AudioFrame> {
return new AudioStream(track, {
sampleRate: this.sampleRate,
numChannels: this.numChannels,
noiseCancellation: this.frameProcessor || this.noiseCancellation,
// Don't let the AudioStream close the processor when the track switches —
// this input stream owns the processor across track changes and closes it
// itself in close().
autoCloseNoiseCancellation: false,
// TODO(AJS-269): resolve compatibility issue with node-sdk to remove the forced type casting
}) as unknown as ReadableStream<AudioFrame>;

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.

🚩 Removal of onStreamInfoUpdated/onCredentialsUpdated depends on rtc-node handling them internally

The old code explicitly called this.frameProcessor?.onStreamInfoUpdated(...) and this.frameProcessor?.onCredentialsUpdated(...) when a track was subscribed (_input.ts:156-164 in old code), and refreshed credentials on TokenRefreshed events. The new code removes all of these, relying on the AudioStream constructor in @livekit/rtc-node to handle stream info and credential propagation internally when it receives the frameProcessor via the noiseCancellation option. This is a correctness assumption that can't be verified from this repo alone — it depends on the AudioStream implementation in @livekit/rtc-node@^0.13.27 actually performing these calls. If the SDK version doesn't handle this internally, the frame processor (e.g., server-side noise cancellation) would not receive the participant/room/credential context it needs to function.

Open in Devin Review

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

// Don't let the AudioStream close the processor when the track switches —
// this input stream owns the processor across track changes and closes it
// itself in close().
autoCloseNoiseCancellation: false,

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.

🚩 autoCloseNoiseCancellation is a new option that must be supported by the rtc-node SDK

The autoCloseNoiseCancellation: false option at _input.ts:167 is passed to the AudioStream constructor. This option doesn't appear anywhere else in this repository — it's a new SDK feature. The catalog pins @livekit/rtc-node to ^0.13.27. If this option was only added in a newer minor/patch version not yet published, the option would be silently ignored (since JS doesn't validate extra constructor options), and the AudioStream would still auto-close the processor on track switches, leading to a use-after-close when the next track tries to use the same processor. Worth confirming the SDK version supports this flag.

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.

2 participants