steep-traffic-80245
07/22/2025, 4:25 PMtall-airline-16756
07/22/2025, 4:25 PMtall-airline-16756
07/22/2025, 4:26 PM@livekit/rtc-node and livekit-server-sdk
◦ Python: livekit package
• Register RPC methods your agent will handle. For example:
◦ Node.js: `room.localParticipant?.registerRpcMethod(
'greet',
async (data) => {
console.log(Received greeting from ${data.callerIdentity}: ${data.payload});
return `Hello, ${data.callerIdentity}!;
}
);
◦ Python: @room.local_participant.register_rpc_method("greet")
async def handle_greet(data):
print(f"Received greeting from {data.caller_identity}: {data.payload}")
return f"Hello, {data.caller_identity}!"
• Invoke RPC methods on other participants:
◦ Node.js: const response = await room.localParticipant!.performRpc({
destinationIdentity: 'recipient-identity',
method: 'greet',
payload: 'Hello from RPC!',
});
◦ Python: response = await room.local_participant.perform_rpc(
destination_identity='recipient-identity',
method='greet',
payload='Hello from RPC!'
)
• Work with RPC data types such as RpcInvocationData (for handler input), PerformRpcRequest (for making calls), and RegisterRpcMethodRequest (for registration).
• Handle errors by throwing RpcError in your handler if needed. Other errors will be sent as "Application Error".
The essential pattern is:
1. Connect to the LiveKit room
2. Register your RPC methods
3. Handle incoming invocations in your handler
4. Call RPC methods on other participants as needed
This enables powerful agent-to-agent or agent-to-client communication using custom RPC methods.
Sources: packages/livekit-rtc/README.md | livekit-rtc/livekit/rtc/_proto/rpc_pb2.py | Remote method calls (RPC) | LiveKit Docs | Web and mobile frontends | LiveKit Docssteep-traffic-80245
07/22/2025, 4:33 PMtall-airline-16756
07/22/2025, 4:33 PM