Skip to content

fix(voice): wait for end-of-turn task when waiting for user inactivity#5792

Merged
longcw merged 1 commit into
mainfrom
longc/fix-wait-for-eou-user-branch
May 22, 2026
Merged

fix(voice): wait for end-of-turn task when waiting for user inactivity#5792
longcw merged 1 commit into
mainfrom
longc/fix-wait-for-eou-user-branch

Conversation

@longcw
Copy link
Copy Markdown
Contributor

@longcw longcw commented May 21, 2026

Summary

_wait_for_inactive only awaited the end-of-turn task in the wait_for_agent branch. But EOU belongs to both:

  • It's part of the user turn — _user_silence_event can be set as soon as VAD/STT detects silence, while the EOU task is still running to confirm the turn boundary. A caller passing wait_for_user=True, wait_for_agent=False could return mid-EOU.
  • It may spawn a new speech handle — so even in the both-True case, the user-side branch could flip user_active=False while EOU was racing to create new agent work.

Fix the race introduced in #5492 that may break the AsyncToolset reply deliver that the tool updates created while EOU is active, and then created two agent replies in parallel.

The end-of-turn task belongs to both the user and the agent: it's part
of the user turn and may spawn a new agent speech handle. Previously it
was only awaited in the wait_for_agent branch, so callers waiting only
on user inactivity could return while an EOU was still pending, and a
fast user-silence flip could race a new speech handle being created.
@chenghao-mou chenghao-mou requested a review from a team May 21, 2026 04:10
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

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 2 additional findings.

Open in Devin Review

@longcw longcw merged commit 6a2ff03 into main May 22, 2026
25 checks passed
@longcw longcw deleted the longc/fix-wait-for-eou-user-branch branch May 22, 2026 00:44
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