Skip to content

fix(agents): bypass AudioResampler when input and output sample rates…#1453

Open
KrishnaShuk wants to merge 2 commits into
livekit:mainfrom
KrishnaShuk:fix/audio-resampler-memory-leak
Open

fix(agents): bypass AudioResampler when input and output sample rates…#1453
KrishnaShuk wants to merge 2 commits into
livekit:mainfrom
KrishnaShuk:fix/audio-resampler-memory-leak

Conversation

@KrishnaShuk
Copy link
Copy Markdown
Contributor

@KrishnaShuk KrishnaShuk commented May 10, 2026

Description

Fixes #1431

Short-circuits the AudioResampler logic natively in utils.ts when the incoming chunk sampleRate perfectly matches the requested outputRate.

This efficiently prevents exhaustive runtime FFI overhead instantiations and stops the runaway RSS memory padding up to several gigabytes over long streaming sessions.

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.

… match

Fixes livekit#1431 by short-circuiting the AudioResampler logic locally when the input chunk sampleRate perfectly bounds with the STT outputRate preventing exhaustive runtime FFI overhead drops and rampant RSS memory leak inflation over long stream execution.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 10, 2026

⚠️ No Changeset found

Latest commit: c50570e

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

devin-ai-integration[bot]

This comment was marked as resolved.

@KrishnaShuk KrishnaShuk marked this pull request as draft May 10, 2026 19:12
@KrishnaShuk KrishnaShuk marked this pull request as ready for review May 10, 2026 20:29
@toubatbrian
Copy link
Copy Markdown
Contributor

@KrishnaShuk Can you confirm if it's working in a real agent session?

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.

Node agents resampleStream() creates Sox resampler even when input/output sample rates match, causing high native memory growth

2 participants