fix(aws): keep realtime session active after stream restart - #6811
Open
uuzzrm wants to merge 2 commits into
Open
fix(aws): keep realtime session active after stream restart#6811uuzzrm wants to merge 2 commits into
uuzzrm wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a retryable Bedrock stream error triggered a session restart, the previous response task could reach its cleanup block after the replacement task had been installed. Its unconditional
_is_sess_active.clear()then stopped the restarted session, leaving Nova Sonic calls silent after the restart.This change makes response-task cleanup ownership-aware: only the task currently stored in
_response_taskmay deactivate the session.Tests
uv run pytest livekit-plugins/livekit-plugins-aws/tests -q(17 passed)uv run pytest tests/test_realtime_fallback.py tests/test_realtime_reply_chat_ctx.py -q(41 passed)uv run ruff checkon the changed source and test filesuv run ruff format --checkon the changed source and test filesgit diff --checkThe regression test covers both the stale response task case and normal cleanup by the current response task.
Fixes #6793
AI assistance
This PR was prepared with AI coding assistance. The change was reviewed against the existing session lifecycle, and the focused tests and lint checks were run locally.