Skip to content

fix(voice): block on_user_turn_exceeded during agent handoff#5858

Merged
longcw merged 1 commit into
mainfrom
longc/fix-user-turn-exceeded-transition
May 27, 2026
Merged

fix(voice): block on_user_turn_exceeded during agent handoff#5858
longcw merged 1 commit into
mainfrom
longc/fix-user-turn-exceeded-transition

Conversation

@longcw
Copy link
Copy Markdown
Contributor

@longcw longcw commented May 27, 2026

Summary

block on_user_turn_exceeded during agent handoff:

  • entry-level guard in on_user_turn_exceeded blocks new tasks
  • re-check inside _user_turn_exceeded_task after the wait phase aborts a task that was already in flight when the transition started; placed before the lock so it respects the existing "never cancel user code" rule

Closes #5852.

Other user-turn handlers check `_scheduling_paused or _new_turns_blocked`
before scheduling, but `on_user_turn_exceeded` was missing that guard. If
the event fires inside the transition window opened by `update_agent()`,
the old activity schedules a speech task — delaying drain and making the
old agent respond instead of the new one. Add the guard at entry and a
matching re-check inside `_user_turn_exceeded_task` after the wait phase
so an already-running task self-aborts when a handoff starts mid-wait.
@chenghao-mou chenghao-mou requested a review from a team May 27, 2026 02:13
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 7b7d131 into main May 27, 2026
26 checks passed
@longcw longcw deleted the longc/fix-user-turn-exceeded-transition branch May 27, 2026 05:55
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.

[Detail Bug] Voice: user turn limit can delay agent handoff and trigger responses from the old agent

2 participants