Speech MEAI (2/6): extract RealtimeAudioProtocol from the Nova session - #61
Draft
GarrettBeatty wants to merge 1 commit into
Draft
Conversation
This was referenced Aug 27, 2026
GarrettBeatty
force-pushed
the
gcbeatty/speech-meai/2-realtime-protocol
branch
from
August 27, 2026 18:02
8f0b241 to
c6edc47
Compare
Phase 2 of the AWS.Speech.MEAI stack. Pure refactor of AWS.Bedrock.MEAI with no behavior change, so the AWS.Speech.MEAI VoiceAgent (PR 4) can reuse the concurrency and marshalling invariants already proven by the Nova session instead of reimplementing them. Moves the provider-neutral, side-effect-free helpers into a new internal RealtimeAudioProtocol: - Tool-payload normalization (NormalizeToolPayload/NormalizeToolArguments and their helpers, plus the max-depth guard and WriteNormalizedValue). - MapRole. - The single-enumeration guard, exposed as TryBeginExclusiveEnumeration / EndExclusiveEnumeration that operate on a caller-owned ref field. The session keeps its _activeStreamingEnumeration field, so the reflection-based concurrency test is unaffected. Left in BedrockNovaRealtimeSession because they are Nova-protocol coupled: the outbound Channel typing and priority queue, ordered DisposeAsync, ParseUsage (Nova usageEvent keys), and SerializeToolResult (Nova toolResult JSON-object wrapping). SerializeToolResult now calls the shared normalizers. Grants AWS.Bedrock.MEAI internals to AWS.Speech.MEAI so the net8 pipeline can call RealtimeAudioProtocol; suppresses CS0436 in AWS.Speech.MEAI for the ExperimentalAttribute polyfill both assemblies define on down-level TFMs. RealtimeAudioProtocol is net8-only, matching the Nova session. All Bedrock/Nova tests pass unchanged (243 net8.0 incl. new helper tests, 173 net472); Speech tests unaffected.
GarrettBeatty
force-pushed
the
gcbeatty/speech-meai/2-realtime-protocol
branch
from
August 27, 2026 18:14
c6edc47 to
bb6a3ef
Compare
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.
Stack (gh-stack style)
Lands on
feature/speech. Each PR targets the branch below it.RealtimeAudioProtocolfrom Nova session ← this PR (base:gcbeatty/speech-meai/1-speech-clients)VoiceAgentcore (funnel, turn detection, clause chunking)AsIRealtimeClient()+ DIWhat this PR does (Phase 2)
Pure refactor of
AWS.Bedrock.MEAI, no behavior change. Extracts the provider-neutral invariants the Nova session already proves into a new internalRealtimeAudioProtocol, so theVoiceAgentpipeline (PR 4) reuses tested code instead of reimplementing it.Moved into
RealtimeAudioProtocol(pure / side-effect-free):NormalizeToolPayload,NormalizeToolArguments,ConvertJsonElementToToolPayload, the max-depth guard, andWriteNormalizedValue.MapRole.TryBeginExclusiveEnumeration(ref int)/EndExclusiveEnumeration(ref int). The session keeps its_activeStreamingEnumerationfield, so the reflection-based concurrency test is untouched.Deliberately left in
BedrockNovaRealtimeSession(Nova-protocol coupled): the outboundChanneltyping + priority queue, orderedDisposeAsync,ParseUsage(NovausageEventkeys), andSerializeToolResult(NovatoolResultJSON-object wrapping).SerializeToolResultnow calls the shared normalizers.Plumbing:
InternalsVisibleTo AWS.Speech.MEAIadded toAWS.Bedrock.MEAIso the net8 pipeline can callRealtimeAudioProtocol.RealtimeAudioProtocolis net8-only (#if NET8_0_OR_GREATER), matching the Nova session.AWS.Speech.MEAI: both assemblies define theExperimentalAttributepolyfill on down-level TFMs, now mutually visible through the new IVT grant. The compiler uses each assembly's local copy.Testing
MapRole), 173 on net472. The relocated normalization tests now targetRealtimeAudioProtocol; the reflection concurrency test is unmodified.AWS.DotNetAI.slnxbuilds 0 errors. Speech tests unaffected (13 / 7).