Skip to content

Conversation

@CathyL0
Copy link
Contributor

@CathyL0 CathyL0 commented Jan 20, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability of asynchronous voice processing with safer cancellation and error handling.
    • More accurate detection of audio playback start so playback is signaled promptly on first frame.
  • Improvements

    • Agent transitions to "thinking" earlier during voice interactions, giving faster user feedback.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

Introduces an earlier "thinking" state transition during pipeline replies, adds defensive guards and narrower exception handling when reading futures, refactors agent state-change emission, and triggers playback_started callbacks on first audio frame for queue and datastream audio outputs.

Changes

Cohort / File(s) Summary
Agent activity
livekit/agents/voice/agent_activity.py
Move agent state to "thinking" earlier in the pipeline reply flow; add guards to async callbacks to check futures for cancellation/done before calling result(); narrow exception handling from BaseException to asyncio.CancelledError and Exception.
Agent session
livekit/agents/voice/agent_session.py
Refactor emission of state-change events to build an AgentStateChangedEvent in a temporary variable before calling emit (semantically identical).
Audio playback — queue output
livekit/agents/voice/avatar/_queue_io.py
Import time and trigger on_playback_started(created_at=time.time()) when the first audio frame is captured (QueueAudioOutput is end of chain).
Audio playback — datastream output
livekit/agents/voice/avatar/_datastream_io.py
Import time and trigger on_playback_started(created_at=time.time()) when stream_writer is first established so first-frame futures are resolved proactively.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • davidzhao
  • longcw
  • rimiakter5612-arch

Poem

🐰 I hopped in early to start the "think",
Futures now guarded before they blink,
Events wrapped tidy, playback sings true,
Small changes, big care — a rabbit's review! 🎵

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately identifies the main changes affecting agent state handling when using QueueAudioOutput and DataStreamAudioOutput components.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@CathyL0 CathyL0 changed the title Chore/debug fix: agent state using QueueAudioOutput Jan 20, 2026
@CathyL0 CathyL0 marked this pull request as ready for review January 20, 2026 03:23
@CathyL0 CathyL0 changed the title fix: agent state using QueueAudioOutput fix: agent state using QueueAudioOutput / DataStreamAudioOutput Jan 20, 2026
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.

1 participant