Unify model and session interface#17
Merged
Merged
Conversation
Collaborator
|
Overall comment regarding file naming convention: Since these files are already located within the bidirectional_streaming directory, we don't need to include "bidirectional_streaming" in each individual file name, eg we could just call base_model, event_type something. |
Merged
| "event": { | ||
| "contentStart": { | ||
| "promptName": self.prompt_name, | ||
| "promptName": self.session_id, |
Collaborator
There was a problem hiding this comment.
I think you replied me, but here is session_id? bad rebase?
| "event": { | ||
| "audioInput": { | ||
| "promptName": self.prompt_name, | ||
| "promptName": self.session_id, |
Collaborator
|
TODO: This pr is a dependency to other ongoing works. Merge this PR now, need to follow up on naming and coding consistency. |
JackYPCOnline
approved these changes
Nov 4, 2025
mehtarac
approved these changes
Nov 4, 2025
mehtarac
approved these changes
Nov 4, 2025
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.
Description
This PR implements a unified bidirectional streaming interface that simplifies the API while maintaining strong typing and provider flexibility. Following the decision from PR #11, we've adopted a unified model interface that combines configuration and connection state in a single class, eliminating the separate session abstraction.
Key Changes
1. Unified Model Interface
Before (Two-Layer):
After (Unified):
2. Unified
send()MethodReplaced multiple content-specific methods with a single polymorphic
send()method:Before:
After:
3. New Typed Input Events
Added
TextInputEventfor consistency with other input event types:4. Simplified Connection Lifecycle
BidirectionalModelnow directly implementsconnect(),send(),receive(), andclose()BidirectionalModelSessionas a separate abstractionBidirectionalModelSession = BidirectionalModel5. Updated All Provider Implementations
6. Comprehensive Unit Tests
Added extensive test coverage for all three providers:
tests/strands/experimental/bidirectional_streaming/models/test_gemini_live.py(500 lines)tests/strands/experimental/bidirectional_streaming/models/test_novasonic.py(551 lines)Benefits
✅ Simpler API: Single interface per model, familiar pattern matching core Strands Agent
✅ Better Type Safety: Explicit typed events for all input types
✅ Cleaner Architecture: Internal separation maintained without exposing complexity
✅ Industry Alignment: Matches patterns from Google Gemini Live and OpenAI Realtime APIs
✅ Backwards Compatible: Alias provided for existing code using
BidirectionalModelSessionRelated Issues
Implements the unified interface decision from #11
Documentation PR
Documentation updates will follow in a separate PR to agents-docs
Type of Change
Breaking change
Testing
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.