feat(aws): expose Nova Sonic session ID on the realtime session - #7327
Open
guiruggiero wants to merge 2 commits into
Open
guiruggiero wants to merge 2 commits into
guiruggiero wants to merge 2 commits into
Conversation
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.
What
Stores Nova Sonic's
sessionIdonRealtimeSession, exposes it as asession_idproperty, and logs it once per stream atINFOlevel.Purely additive — no change to the existing event flow.
Why
I'm the PM for Amazon Nova Sonic. When a customer running Sonic through LiveKit files a support ticket with us, the first thing we ask for is the session ID, and today there's no easy way for them to get it — which blocks debugging on our side.
Nova Sonic stamps
sessionIdon every server event and it's the canonical identifier for tracing a session on the service side, but the plugin never stores it. The only place it currently surfaces is inside the DEBUG-levellog_event_data()call oncompletionStart, so users have to run the worker at--log-level debugand scrape the raw JSON out of thelk.pii.event_datafield. Thelog_event_data()call in_handle_usage_eventis commented out, so the earliest occurrence isn't logged at all.Details
Why
usageEventrather thancompletionStart:usageEventis the earliest server event carryingsessionId. I confirmed this against the live Bedrock API with a session that sends only the init sequence (sessionStart→promptStart→ SYSTEM → SYSTEM_SPEECH) and no user input at all: fourusageEvents arrived, each carryingsessionId, before anycompletionStart. Capturing it here means the ID is available before the user has said anything, so it survives a session that fails early.I also traced a full session (100+ events —
usageEvent,completionStart,contentStart,textOutput,audioOutput,contentEnd,completionEnd) and every one carried an identicalsessionId, so reading it off any single event is equivalent.usageEventis simply the first opportunity.Why log on change rather than once:
_session_recycle_timerandinitialize_streams(is_restart=True)open a new Bedrock stream — ahead of the service's session-duration limit and on credential refresh — and each new stream is assigned a newsessionId. So a singleRealtimeSessionlegitimately spans several IDs. The!=guard emits one line per ID instead of one perusageEvent.Naming:
session_id -> str | Nonefollows the existing convention in the codebase — the OpenAI realtime plugin (gpt_live_model.py), the AssemblyAI and Speechmatics STT plugins, andinference/avatar.pyall expose the same shape.Checks
ruff checkandruff format --checkpass, verified against the0.15.22pinned inuv.lockCHANGELOG.mdor manifest edits, per CONTRIBUTING.md