Repository navigation
Conversation
RoomSessionTransport opened an incremental byte stream per session message, which always costs a header, a chunk and a trailer packet on the reliable data channel and is never compressed. Session events are small and frequent (~90 per agent turn, mostly session_usage_updated), so this was a large share of the data sent to every participant. LocalParticipant.send_bytes knows the whole payload up front, so the SDK can deliver a small message as a single inline packet, and compress a large one, for receivers that support data streams v2. Measured against a protocol-3 JS client, one agent turn dropped from ~52 KB / 354 to ~37 KB / 170 data channel messages. Requires livekit-rtc with LocalParticipant.send_bytes (livekit/python-sdks feat/rtc-send-bytes); the livekit pin must be bumped once that is released. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
lk.agent.session messages with one-shot send_bytes instead of stream_bytes
xianshijing-lk
approved these changes
Oct 12, 2026
This branch has not been deployed
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.
Summary
RoomSessionTransport.send_messagenow sends eachlk.agent.sessionmessage with the one-shotLocalParticipant.send_bytesinstead of opening an incrementalstream_bytesstream per message.With
stream_bytes, an incremental stream always results in three packets being sent on the reliable data channel (header, chunk, trailer) and is never compressed.With
send_bytesthe SDK knows the whole payload up front, so for receivers that support data streams v2 it can send a small message as a single inline packet, and compress a large one.Why it matters
Session events are small and frequent, and today they go to every participant in the room, because the room session host is created with no remote identity. Measured against a JS client (
clientProtocolof 3), one agent turn sent ~95 session messages: 89×session_usage_updated, 4×agent_state_changed, 2×conversation_item_added. On the client's data channel:stream_bytes(today)send_bytes(this PR)On constrained mobile links, that traffic queues ahead of RPCs and transcriptions on the reliable channel. That's the head-of-line blocking behind customer reports of agent → client RPC connection timeouts.
TODO
LocalParticipant.send_bytesbeing merged and released inlivekit-rtc(livekit/python-sdks PR: feat(rtc): add LocalParticipant.send_bytes python-sdks#858)livekit-rtcpackage dependency