Skip to content

Speech MEAI (2/6): extract RealtimeAudioProtocol from the Nova session - #61

Draft
GarrettBeatty wants to merge 1 commit into
gcbeatty/speech-meai/1-speech-clientsfrom
gcbeatty/speech-meai/2-realtime-protocol
Draft

Speech MEAI (2/6): extract RealtimeAudioProtocol from the Nova session#61
GarrettBeatty wants to merge 1 commit into
gcbeatty/speech-meai/1-speech-clientsfrom
gcbeatty/speech-meai/2-realtime-protocol

Conversation

@GarrettBeatty

Copy link
Copy Markdown
Collaborator

Stack (gh-stack style)

Lands on feature/speech. Each PR targets the branch below it.

Review #58 and #59 first; this branch is stacked on them.

What 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 internal RealtimeAudioProtocol, so the VoiceAgent pipeline (PR 4) reuses tested code instead of reimplementing it.

Moved into RealtimeAudioProtocol (pure / side-effect-free):

  • Tool-payload normalization: NormalizeToolPayload, NormalizeToolArguments, ConvertJsonElementToToolPayload, the max-depth guard, and WriteNormalizedValue.
  • MapRole.
  • The single-enumeration guard, as TryBeginExclusiveEnumeration(ref int) / EndExclusiveEnumeration(ref int). The session keeps its _activeStreamingEnumeration field, so the reflection-based concurrency test is untouched.

Deliberately left in BedrockNovaRealtimeSession (Nova-protocol coupled): the outbound Channel typing + priority queue, ordered DisposeAsync, ParseUsage (Nova usageEvent keys), and SerializeToolResult (Nova toolResult JSON-object wrapping). SerializeToolResult now calls the shared normalizers.

Plumbing:

  • InternalsVisibleTo AWS.Speech.MEAI added to AWS.Bedrock.MEAI so the net8 pipeline can call RealtimeAudioProtocol.
  • RealtimeAudioProtocol is net8-only (#if NET8_0_OR_GREATER), matching the Nova session.
  • Suppressed CS0436 in AWS.Speech.MEAI: both assemblies define the ExperimentalAttribute polyfill on down-level TFMs, now mutually visible through the new IVT grant. The compiler uses each assembly's local copy.

Testing

  • All Bedrock/Nova unit tests pass unchanged: 243 on net8.0 (includes new direct tests for the guard and MapRole), 173 on net472. The relocated normalization tests now target RealtimeAudioProtocol; the reflection concurrency test is unmodified.
  • Full AWS.DotNetAI.slnx builds 0 errors. Speech tests unaffected (13 / 7).

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
GarrettBeatty force-pushed the gcbeatty/speech-meai/2-realtime-protocol branch from c6edc47 to bb6a3ef Compare August 27, 2026 18:14
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.

1 participant