Skip to content

fix(avatar): skip removal when participant missing#2072

Merged
toubatbrian merged 4 commits into
mainfrom
talker-sidled-warheads
Jul 20, 2026
Merged

fix(avatar): skip removal when participant missing#2072
toubatbrian merged 4 commits into
mainfrom
talker-sidled-warheads

Conversation

@rosetta-livekit-bot

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

Copy link
Copy Markdown
Contributor

Summary

  • Port Python avatar cleanup behavior from fix(avatar): skip removal if avatar not found in the room agents#6486.
  • Skip warning when avatar participant removal fails because the participant is already absent from the room.
  • Keep warning behavior for all other removal failures.
  • Add focused cleanup/error-branch tests and a patch changeset for @livekit/agents.

Source diff coverage

Classification
  • livekit-agents/livekit/agents/voice/avatar/_types.py: ported to agents/src/voice/avatar/avatar_session.ts. The Python change catches LiveKit API TwirpError with code == "not_found" during avatar participant removal and logs debug instead of warning. The JS SDK does not export TwirpError, so this was adapted to a structural code === "not_found" check on the caught error while preserving warning behavior for all other errors.
  • Source tests: the Python diff added none. Focused JS regressions were added to cover both error branches, participant-removal arguments, listener cleanup, and resolved shutdown.

Validation

  • Exact head: a5bf1ebb17b4d16d827d8aea57cffc86c713b649.
  • pnpm test -- agents/src/voice/avatar/avatar_session.test.ts passed: 4/4.
  • pnpm --filter @livekit/agents build passed.
  • Isolated package lint passed with no errors and pre-existing warnings; the normal linked-worktree command encountered duplicate ESLint plugin discovery.
  • Focused Prettier check passed.
  • Independent spec-compliance review approved.
  • Independent code-quality review approved.

Runtime validation

  • Cue voice E2E is not applicable to this shutdown-only boundary. The changed path handles RoomServiceClient.removeParticipant errors after the avatar session closes and emits no framework event that Cue can distinguish.
  • The closest behavior-level verification uses a controlled RoomServiceClient boundary. Tests prove code: "not_found" logs at debug without warning, generic errors retain warning behavior, both call removeParticipant with the expected room/identity, both detach the registered agent-session and room listeners, and both allow aclose() to resolve.

Infrastructure gaps

  • None. The target has the corresponding avatar cleanup path and LiveKit server SDK error objects expose the needed code field.

Ported from livekit/agents#6486

Original PR description

some avatar provider may disconnect to the room before we cleanup

@rosetta-livekit-bot
rosetta-livekit-bot Bot requested a review from a team as a code owner July 20, 2026 06:00
@changeset-bot

changeset-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a5bf1eb

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

This PR includes changesets to release 37 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-anthropic Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-azure Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did 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-perplexity 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-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai 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

@rosetta-livekit-bot
rosetta-livekit-bot Bot requested a review from longcw July 20, 2026 06:01

@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 potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

toubatbrian and others added 3 commits July 20, 2026 11:34
Co-authored-by: Cursor <cursoragent@cursor.com>
Use typed session, room, job-context, logger, and audio-output fixtures so cleanup coverage conforms to repository type-safety rules.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@toubatbrian
toubatbrian merged commit 41411c8 into main Jul 20, 2026
6 checks passed
@toubatbrian
toubatbrian deleted the talker-sidled-warheads branch July 20, 2026 21:14
@github-actions github-actions Bot mentioned this pull request Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant