little-activity-13208
07/15/2025, 3:41 PMawait ctx.api.room.update_room_metadata(
api.UpdateRoomMetadataRequest(
room=ctx.room.name,
metadata=json.dumps(updated_metadata)
)
)
# await fetch_until_success(lambda room_info: room_info.metadata == json.dumps(updated_metadata))
print("waiting")
await asyncio.sleep(5)
print("done waiting")
await ctx.api.room.delete_room(
api.DeleteRoomRequest(
room=ctx.room.name,
)
)
Fetching room from the api directly, however, does show the updated metadata, as the below code checks the two metadata as identical:
async def fetch_room_info():
"""Fetch room information from the LiveKit server"""
ctx = get_job_context()
room_info = await ctx.api.room.list_rooms(
api.ListRoomsRequest(names=[ctx.room.name])
)
return room_info.rooms[0]
async def fetch_until_success(end_condition: Callable[[Any], bool], max_retries: int = 10):
"""Fetch room information from the LiveKit server until the end condition is met"""
for _ in range(max_retries):
room_info = await fetch_room_info()
print(f"Room info: {room_info}")
if end_condition(room_info):
print(f"End condition met: {room_info}")
return room_info, True
await asyncio.sleep(1)
return None, False
Any help would be appreciated, thanks!future-glass-56154
10/07/2025, 11:53 PMfuture-glass-56154
10/08/2025, 2:20 PMrefined-appointment-81829
10/08/2025, 2:42 PMfuture-glass-56154
10/08/2025, 3:27 PMuserdata = self.session.userdata
if not userdata.livekit_api:
livekit_url = get_env_var("LIVEKIT_URL")
api_key = get_env_var("LIVEKIT_API_KEY")
api_secret = get_env_var("LIVEKIT_API_SECRET")
logger.debug(f"Initializing LiveKit API client with URL: {livekit_url}")
userdata.livekit_api = api.LiveKitAPI(
url=livekit_url, api_key=api_key, api_secret=api_secret
)
transfer_request = proto_sip.TransferSIPParticipantRequest(
participant_identity=participant_identity,
room_name=userdata.ctx.room.name,
transfer_to=transfer_to,
play_dialtone=True,
)
logger.debug(f"Transfer request: {transfer_request}")
current_metadata = self.session.userdata.ctx.room.metadata or "{}"
room_name = self.session.userdata.ctx.room.name
metadata_dict = json.loads(current_metadata)
metadata_dict.update({"transfer": True})
await userdata.livekit_api.room.update_room_metadata(
api.UpdateRoomMetadataRequest(
room=room_name, metadata=json.dumps(metadata_dict)
)
)
logger.info(f"Updated metadata {self.session.userdata.ctx.room.metadata}")
await userdata.livekit_api.sip.transfer_sip_participant(transfer_request)
logger.info(
f"Successfully transferred participant {participant_identity} to {transfer_to}"
)
This metadata update happened at 111914,035 according to my logs and the webhook recieved the participant_left event at 111915.632.
I've also tried pausing the code with a sleep timer before the transfer happens to increase the time between the metadata update and the webhook event, but the metadata on the webhook side is still not updated.