Hi, I would like to ask you about this error and h...
# agents
h
Hi, I would like to ask you about this error and how to avoid it:
Copy code
node_modules/@livekit/agents/src/stream/deferred_stream.ts:52
throw new Error('Stream source already set');
(note: it worked with 0.x version of node.js) Steps to reproduce: 1. use
multi_agent.ts
(from agents-js/examples/src/, main branch) 2. use this session: const session = new voice.AgentSession({llm: new openai.realtime.RealtimeModel(),userData: userdata}); 3. in session.start, add
inputOptions.closeOnDisconnect
as
false
4. remove whole
prewarm
step in
defineAgent
5. create node.js endpoint, ask for a new token:
Copy code
const at = new AccessToken(process.env.LIVEKIT_API_KEY, process.env.LIVEKIT_API_SECRET, {
      identity: userId,
    });
    at.addGrant({ roomJoin: true, room: `room-of-${userId}` });
    const roomConfig = new RoomConfiguration({
      agents: [
        new RoomAgentDispatch({
          agentName: "my-agent",
        }),
      ],
      departureTimeout: 180,
      emptyTimeout: 5,
    });
    at.roomConfig = roomConfig;
const token = await at.toJwt();
    return res.json({ token });
6. on front end, run LiveKitRoom from "@livekit/components-react" like this:
Copy code
<LiveKitRoom token={liveKitToken} serverUrl={process.env.LIVEKIT_URL} audio={true}>
          <RoomAudioRenderer />
        </LiveKitRoom>
7. fetch token, save it into react state, use it in LiveKitRoom 8. agent starts, you can talk, etc. 9. disconnect the user and let him to connect back (refresh the browser), that means we use same userId, same identity, same room name, but fresh token 10. server error 'Stream source already set'