silly-baker-11446
08/30/2025, 8:51 PMtall-airline-16756
08/30/2025, 8:52 PMtall-airline-16756
08/30/2025, 8:52 PMsuper().llm_node(). This context only gets initialized when the agent is actively running inside an AgentSession. To fix this, just make sure you:
• Create an AgentSession before doing any LLM operations.
• Start the session with `await session.start(agent=agent, room=ctx.room)`—this sets up the agent’s activity context.
• Call super().llm_node() only while the session is active.
Here’s a quick example of how it should look:
from livekit.agents import AgentSession
session = AgentSession() # Create the session
await session.start(agent=agent, room=ctx.room) # Start with agent and room
# Now the agent is active and can use super().llm_node()
Just double-check that your AgentTask is set up and used inside this active session to avoid running into that RuntimeError. Hope this helps!
Sources: livekit-agents/livekit/agents/voice/generation.pysilly-baker-11446
08/30/2025, 8:54 PMtall-airline-16756
08/30/2025, 8:54 PMsilly-baker-11446
08/30/2025, 9:00 PMabundant-father-33863
09/26/2025, 8:41 AM