From 99c27357c6b4d13213d3c77d421d3eea4b5fdd83 Mon Sep 17 00:00:00 2001 From: Robin Andeer Date: Tue, 26 May 2026 11:27:31 -0400 Subject: [PATCH] feat(core): consume session immediately when pollUntilReady reaches READY Fire POST /consume as soon as the session is READY so the Calliope worker can start the LiveKit participant wait while the client connects. --- packages/core/src/api/poll.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/core/src/api/poll.ts b/packages/core/src/api/poll.ts index 554cbc3..e4310bf 100644 --- a/packages/core/src/api/poll.ts +++ b/packages/core/src/api/poll.ts @@ -1,3 +1,4 @@ +import { consumeSession } from './consume'; import { AvatarError } from '../error'; export interface PollUntilReadyOptions { @@ -79,6 +80,13 @@ export async function pollUntilReady( 'Session is READY but sessionKey is missing', ); } + // Mark consumed immediately so the worker starts the participant wait + // while the caller prepares the LiveKit connection. + await consumeSession({ + sessionId, + sessionKey: session.sessionKey, + baseUrl, + }); return { sessionId, sessionKey: session.sessionKey }; }