Skip to content

feat: surface agent backchannel opportunity as a public event - #6985

Open
AinaLuc wants to merge 1 commit into
livekit:mainfrom
AinaLuc:feat/agent-backchannel-opportunity-event
Open

feat: surface agent backchannel opportunity as a public event#6985
AinaLuc wants to merge 1 commit into
livekit:mainfrom
AinaLuc:feat/agent-backchannel-opportunity-event

Conversation

@AinaLuc

@AinaLuc AinaLuc commented Aug 26, 2026

Copy link
Copy Markdown

Summary

  • Promotes the previously-internal _AgentBackchannelOpportunityEvent to a public AgentBackchannelOpportunityEvent, emitted on AgentSession (agent_backchannel_opportunity) and dispatched to a new Agent.on_backchannel_opportunity() hook, so agents can react to mid-turn pauses with short acknowledgment phrases ("mm-hmm", "right", etc).
  • Adds an end_of_turn_margin property to the event as a risk axis for picking an appropriate phrase.
  • Fixes a race in AudioRecognition.update_vad(): the previous VAD task was cancelled after the new one was already created, so a rapid update_vad call could let a stale task's cleanup clobber the new stream/channel. Adds a generation counter so a superseded VAD task's events and cleanup are ignored.

Test plan

  • make check (format, lint, type-check)
  • uv run pytest --unit
  • Manual test: agent session with turn detection enabled, verify on_backchannel_opportunity fires and update_vad swap doesn't leave the session in a stuck speaking state

🤖 Generated with Claude Code

@AinaLuc
AinaLuc requested a review from a team as a code owner August 26, 2026 09:45
@CLAassistant

CLAassistant commented Aug 26, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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

Open in Devin Review

Promote the previously-internal _AgentBackchannelOpportunityEvent to a
public AgentBackchannelOpportunityEvent, emitted on AgentSession and
dispatched to a new Agent.on_backchannel_opportunity() hook so agents
can react to mid-turn pauses with acknowledgment phrases.

Also fixes a race in AudioRecognition.update_vad(): the old VAD task
was cancelled after the new one was already created/assigned, so a
rapid update could have the old task's cleanup clobber the new
stream/channel. Introduces a generation counter so a stale VAD task's
events and cleanup are ignored once superseded.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@AinaLuc
AinaLuc force-pushed the feat/agent-backchannel-opportunity-event branch from e970a88 to 5c591ec Compare August 26, 2026 09:53
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