green-judge-63955
08/17/2025, 6:04 PMtall-airline-16756
08/17/2025, 6:04 PMtall-airline-16756
08/17/2025, 6:05 PMgreen-judge-63955
08/17/2025, 6:05 PMtall-airline-16756
08/17/2025, 6:05 PMfrom dataclasses import dataclass
@dataclass
class MySessionInfo:
user_name: str | None = None
age: int | None = None
from livekit.agents import AgentSession
session = AgentSession[MySessionInfo](
userdata=MySessionInfo(),
# ... other parameters like tts, stt, llm, etc.
)
With this setup, the userdata is available throughout your agent’s workflow as session.userdata, and you can also access it inside function tools via the RunContext.
If you’re dealing with more complex state management, another option is to use participant attributes or metadata. These get stored and synced by the LiveKit server and work well for sharing smaller pieces of state across participants.
Feel free to ask if you want me to walk you through more examples or details tailored to your project!