Skip to content

Conversation

@chenghao-mou
Copy link
Member

@chenghao-mou chenghao-mou commented Jan 21, 2026

This should close #4530

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of AWS real-time streaming by enhancing error handling to automatically recover from transient connection issues.

✏️ Tip: You can customize this high-level summary in your review settings.

@chenghao-mou chenghao-mou requested a review from a team January 21, 2026 14:57
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

📝 Walkthrough

Walkthrough

This change adds exception handling for InvalidEventBytes from the smithy_aws_event_stream library to the realtime model's response processing method. The exception is now treated as a retryable error that triggers session restart, aligning with existing error recovery patterns.

Changes

Cohort / File(s) Summary
Realtime Model Error Handling
livekit/plugins/aws/experimental/realtime/realtime_model.py
Adds import of InvalidEventBytes and includes it in the retryable exception handler within _process_responses method to enable graceful recovery via session restart.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A stream hiccup, once a fatal blow,
Now catches gracefully and starts anew.
InvalidEventBytes won't steal the show—
The session restarts, fresh as morning dew! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'handle invalid bytes error' directly describes the main change: catching and handling the InvalidEventBytes exception as a recoverable error.
Linked Issues check ✅ Passed The pull request fully implements the proposed solution from issue #4530 by importing InvalidEventBytes and adding it to the retryable exceptions caught in _process_responses().
Out of Scope Changes check ✅ Passed All changes are directly scoped to resolving issue #4530; only the necessary import and exception handling logic were added.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ad6e4b and ad61c57.

📒 Files selected for processing (1)
  • livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realtime/realtime_model.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Format code with ruff
Run ruff linter and auto-fix issues
Run mypy type checker in strict mode
Maintain line length of 100 characters maximum
Ensure Python 3.9+ compatibility
Use Google-style docstrings

Files:

  • livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realtime/realtime_model.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: livekit-plugins-deepgram
  • GitHub Check: livekit-plugins-openai
  • GitHub Check: livekit-plugins-cartesia
  • GitHub Check: unit-tests
  • GitHub Check: type-check (3.9)
  • GitHub Check: type-check (3.13)
🔇 Additional comments (2)
livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realtime/realtime_model.py (2)

1492-1503: Retryable handling for InvalidEventBytes looks correct.

Restarting the session and breaking the loop aligns with the recoverable-stream pattern and avoids reading from a potentially corrupted stream.

Please confirm via a repro or integration test that InvalidEventBytes is emitted on the output_stream.receive() path and that the restart path recovers cleanly.


34-34: No changes needed. The InvalidEventBytes exception is properly exported from smithy_aws_event_stream==0.2.0 (pinned in uv.lock). The import at line 34 is valid and will not cause a runtime ImportError.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@chenghao-mou chenghao-mou merged commit 49420fc into main Jan 21, 2026
20 checks passed
@chenghao-mou chenghao-mou deleted the fix/aws-realtime-invalid-bytes-error branch January 21, 2026 17:56
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.

InvalidEventBytes exception should be caught and handled as recoverable

3 participants