adorable-engine-68435
10/24/2025, 11:57 AMtall-airline-16756
10/24/2025, 11:57 AMtall-airline-16756
10/24/2025, 11:57 AMlocal_participant object becomes available only after the agent has successfully connected to the room. To smoothly register an RPC method when an agent enters a room, it’s important to first make sure the connection is fully established.
Here’s a friendly reminder of the correct sequence:
async def entrypoint(ctx: JobContext):
print("Starting game host agent")
await ctx.connect() # Ensure connection is established
# Now it's safe to register RPC methods
ctx.room.local_participant.register_rpc_method(
"host.start_game", self._start_game
)
ctx.room.local_participant.register_rpc_method(
"host.end_game", self._end_game
)
ctx.room.local_participant.register_rpc_method(
"host.update_difficulty", self._update_difficulty
)
Just remember to call ctx.connect() before you access ctx.room.local_participant. This way, the local participant will be ready and waiting for you to register your RPC methods without any hiccups.
Sources: agent/game_host.py | avatars/hedra/education_avatar/agent.py | Remote method calls (RPC) | LiveKit Docs