Skip to content

fix(aws): keep realtime session active after stream restart - #6811

Open
uuzzrm wants to merge 2 commits into
livekit:mainfrom
uuzzrm:codex/fix-aws-realtime-restart
Open

fix(aws): keep realtime session active after stream restart#6811
uuzzrm wants to merge 2 commits into
livekit:mainfrom
uuzzrm:codex/fix-aws-realtime-restart

Conversation

@uuzzrm

@uuzzrm uuzzrm commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

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_task may 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 check on the changed source and test files
  • uv run ruff format --check on the changed source and test files
  • git diff --check

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

@uuzzrm
uuzzrm requested a review from a team as a code owner August 11, 2026 22:56

@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

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.

AWS Realtime Nova Sonic - Failure to recover properly from retryable bedrock error: ModelStreamErrorException

1 participant