square-activity-46232
08/06/2025, 11:21 PMignoring byte stream with topic 'lk.agent.pre-connect-audio-buffer', no callback attached
tall-airline-16756
08/06/2025, 11:21 PMtall-airline-16756
08/06/2025, 11:21 PMignoring byte stream with topic 'lk.agent.pre-connect-audio-buffer', no callback attached
, follow these steps:
1. Ensure Proper Pre-Connect Buffer Setup: During the initial connection, register the appropriate byte stream handler for the topic lk.agent.pre-connect-audio-buffer
.
2. Re-register Handlers on Reconnect: When reconnecting, re-register the byte stream handler for the topic. Connection state changes can clear handlers, so this step is crucial.
3. Implement Reconnect Handling:
◦ Re-register byte stream handlers after reconnection.
◦ Re-publish local tracks to maintain the session.
1. Verify Agent Side Configuration: Ensure agents are configured to handle pre-connect audio buffers by registering the appropriate handler during initialization.
2. Error Handling: The error indicates a missing handler. Double-check that the handler is registered before sending data and remains registered through connection state changes.
Here’s an example of registering the handler:
// Register the byte stream handler during initialization
room.registerByteStreamHandler('lk.agent.pre-connect-audio-buffer', async (reader, participantId) => {
try {
const data = await reader.readAll();
console.log('Received pre-connect audio buffer from participant:', participantId);
} catch (error) {
console.error('Error handling pre-connect audio buffer:', error);
}
});
And for reconnection:
// During reconnection, re-register the handler
room.on("reconnected", () => {
room.registerByteStreamHandler('lk.agent.pre-connect-audio-buffer', async (reader, participantId) => {
try {
const data = await reader.readAll();
console.log('Reconnected: Received pre-connect audio buffer from participant:', participantId);
} catch (error) {
console.error('Reconnected: Error handling pre-connect audio buffer:', error);
}
});
});
By ensuring proper handler registration and re-registration during reconnection, you should be able to resolve the error and maintain functionality.
Sources: livekit-agents/livekit/agents/voice/avatar/_datastream_io.py | lib/src/core/engine.dart | livekit/src/rtc_engine/mod.rs | livekit-rtc/livekit/rtc/room.py