Does agent have access to session. Can I simply wr...
# ask-ai
b
Does agent have access to session. Can I simply write self.session?
t
Thanks for reaching out, Harsh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
In the LiveKit Agent SDK: • Within Agent classes, you can access the session directly as
self.session
. For example, in your agent's methods,
self.session
provides access to speech, user data, conversation history, and more. • Within function tools (i.e., code annotated with
@function_tool
), you access the session via
context.session
, where
context
is of type
RunContext
passed as a parameter. Directly using
self.session
is appropriate inside Agent classes, but in other contexts (like standalone tools), use
context.session
from the function signature. Sources: README.md | pipeline-llm/large_context.py | Tool definition and use | LiveKit Docs