polite-oil-10264
07/14/2025, 4:05 PMtall-airline-16756
07/14/2025, 4:05 PMtall-airline-16756
07/14/2025, 4:05 PMroom.metadata
in your Python agent by reading the metadata
property of the Room
object. Typically, metadata is stored as a JSON string, so you should parse it to extract the desired fields. Here’s a simple example:
import json
async def entrypoint(ctx):
await ctx.connect()
if ctx.room.metadata:
try:
metadata = json.loads(ctx.room.metadata)
instructions = metadata.get("instructions", "Default instructions")
except json.JSONDecodeError:
instructions = ctx.room.metadata
else:
instructions = "Default instructions"
# Now you can use the instructions in your agent logic.
• Room metadata is read-only for clients; it must be set via server APIs but is accessible to all participants, including agents.
• If your application updates instructions while the agent is running, you can listen for the room_metadata_changed
event for updates.
This method lets your agent retrieve and act on instructions included in room.metadata
Sources: livekit-protocol/livekit/protocol/agent_dispatch.pyi | External data and RAG | LiveKit Docs | README.md | Room metadata | LiveKit Docs