Skip to content

perf(agents): prepare audio publication during native async connect - #8746

Draft
xianshijing-lk wants to merge 8 commits into
mainfrom
sxian/CLT-3610/fast-track-publication-session-api
Draft

xianshijing-lk wants to merge 8 commits into
mainfrom
sxian/CLT-3610/fast-track-publication-session-api

Conversation

@xianshijing-lk

@xianshijing-lk xianshijing-lk commented Nov 23, 2026 •

Copy link
Copy Markdown

Session startup can describe its audio publication before connecting and initialize activity/greeting generation concurrently. The audio output now passes only its source, name and complete publication options; native track creation happens inside Rust's asynchronous connect task, keeping cold native setup off the Python event loop. After connect, output adopts the returned track/publication instead of publishing twice.

AgentSession's public API is unchanged. JobContext.connect adds publish_audio_tracks while retaining publish_tracks; older RTC wheels retain ordinary publication. The output preserves subscription waiting, name changes and normal publication fallback. The application example starts connection/activity/output concurrently and generates its greeting from on_enter.

Dependencies: livekit/python-sdks#963 and livekit/rust-sdks#1732, stacked on Rust #1704. Supporting single-PC servers use Rust's existing JOIN path; other configurations retain fallback publication.

Validation: 160 RoomIO/startup/translation tests passed. Companion validation: 23 focused RTC tests, 13 staging integration tests, native build/format and 39 FFI unit tests. Coverage includes source-description forwarding, adoption without synchronous creation, single/dual PC, repeated destruction, cancellation, rejection and partial invalid input.

Latest paired staging benchmark compares the previous synchronous-preparation PR implementation with this native preparation fix: 24 measured browser sessions plus six warmups; median ICE RTT 62 ms; all received non-silent audio and message acknowledgements, all warm processes and clean shutdowns.

Controlled case Before first audible audio After Difference of medians
Immediate activity and PCM 1,302 ms 1,302 ms Unchanged
Activity initialization +1,200 ms 1,929 ms 1,808 ms 121 ms faster
First PCM generation +1,200 ms 1,909 ms 1,808 ms 101 ms faster

Activity-start delay fell from 102.1 to 3.8 ms. In the delayed-activity case, ready UI and first message acknowledgement improved by about 124 ms each. This resolves the preparation regression found by the earlier pre/post study. Both arms already publish on JOIN, so it does not measure the two-RTT signaling saving. Immediate startup still waits on subscription/media readiness. Synthetic greetings and asynchronous delays are used; real LLM/TTS timing remains unverified.

Evidence, samples, recordings and reproduction: native preparation report. The earlier actual pre-PR and native signaling reports remain available and clearly identify their versions and limitations.



def write_mark(path: Path, name: str, **fields):
with path.open("a") as f:
@xianshijing-lk xianshijing-lk changed the title feat(agents): prepare audio publication alongside session startup perf(agents): prepare audio publication during native async connect Nov 24, 2026

This branch has not been deployed

No deployments
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.

2 participants