Skip to content

fix(voice): make commit_user_turn await turn processing - #7688

Closed
icebear02 wants to merge 12 commits into
livekit:mainfrom
icebear02:fix/commit-user-turn-barrier
Closed

icebear02 wants to merge 12 commits into
livekit:mainfrom
icebear02:fix/commit-user-turn-barrier

Conversation

@icebear02

Copy link
Copy Markdown

Summary

  • keep the existing Future[str] API
  • wait for the manual turn's end-of-turn and user-turn processing before resolving
  • shield internal turn processing from caller cancellation
  • document the stronger resolution contract

Why

commit_user_turn() currently resolves after end-of-turn handling is only scheduled. A caller that awaits commit_user_turn(skip_reply=True) and immediately calls generate_reply() can therefore race the chat-context append and generate against stale history.

This keeps the public return type unchanged and scopes the fix to the existing manual-turn lifecycle instead of relying on the global speech_created event.

Tests

  • added focused unit coverage for the current EOU/turn-processing barrier
  • verified previous-turn tasks are not awaited
  • verified cancelling the returned future does not cancel internal turn processing
  • ruff check, ruff format --check, and Python compilation passed locally
  • full unit suite is left to CI because the repository's private Krisp development dependency is unavailable in the local offline environment

Fixes #7585

@CLAassistant

CLAassistant commented Oct 9, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@icebear02
icebear02 marked this pull request as ready for review October 9, 2026 10:18
@icebear02
icebear02 requested a review from a team as a code owner October 9, 2026 10:18
devin-ai-integration[bot]

This comment was marked as resolved.

Wait for replacement EOU tasks, propagate processing failures, and keep turn completion pending until the user message reaches chat history.
Cover replacement EOU tasks, processing failures, and the pipeline history-commit barrier.

@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.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 1 new potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Wait for chat-history insertion only from commit_user_turn while preserving the existing interruption and scheduling lifecycle.
Verify commit_user_turn waits for the chat-history barrier without delaying internal user-turn completion.
Return None explicitly on non-reply paths to satisfy the strengthened internal task result type.
devin-ai-integration[bot]

This comment was marked as resolved.

Follow a resumed user to the replacement EOU task and wait for the previous turn message before processing an overlapping turn.
Cover replacement EOU creation after resumed speech and the previous-message barrier for overlapping turns.
devin-ai-integration[bot]

This comment was marked as resolved.

Wait for the previous message barrier without allowing an earlier reply failure to drop the next user turn.
Verify an earlier reply failure cannot prevent an overlapping user turn from being processed.
@lumina678

Copy link
Copy Markdown

Superseded by #7702. I accidentally opened this PR from my secondary account, @icebear02, instead of my primary account, @lumina678. The replacement contains the same final implementation rebased on current main and consolidated into one clean commit. Please continue review on #7702; this PR will be closed to avoid duplicate review.

@icebear02 icebear02 closed this Oct 9, 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.

Return the SpeechHandle from commit_user_turn or ensure await session.commit_user_turn(...) commits to chat context on resolve

3 participants