```{"message": "Task exception was never retrieved...
# ask-ai
f
Copy code
{
  "message": "Task exception was never retrieved\nfuture: <Task finished name='Task-27853' coro=<CodingAgent.async_handle_text_stream() done, defined at /app/agents/abse_coding_agent.py:32> exception=RuntimeError('no activity context found, the agent is not running')>\nTraceback (most recent call last):\n  File \"/app/agents/abse_coding_agent.py\", line 36, in async_handle_text_stream\n    reply = await self.session.generate_reply(user_input=text)\n                  ^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.13/site-packages/livekit/agents/voice/agent.py\", line 574, in session\n    return self._get_activity_or_raise().session\n           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^\n  File \"/usr/local/lib/python3.13/site-packages/livekit/agents/voice/agent.py\", line 319, in _get_activity_or_raise\n    raise RuntimeError(\"no activity context found, the agent is not running\")\nRuntimeError: no activity context found, the agent is not running",
  "level": "ERROR",
  "name": "asyncio",
  "pid": 23332,
  "job_id": "AJ_ZRNjvbGQ8jiR",
  "timestamp": "2025-07-28T16:07:12.624106+00:00"
}
explain this error
t
Thanks for reaching out, jitendra. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The error "no activity context found, the agent is not running" occurs when an operation is attempted on a LiveKit agent that requires the agent to be actively running, but the agent is not currently in a running state. This error is raised by the internal method
_get_activity_or_raise()
when the agent's activity context (
self._activity
) is
None
. The activity context represents the agent's active session and processing pipeline, including: • The current processing pipeline (e.g., STT, LLM, TTS components) • Active speech recognition and generation tasks • Session state and chat context • Real-time session management (if using RealtimeModel) When the agent is not running, this activity context is unavailable, and operations that depend on it will fail with this error. Resolution: 1. Ensure the agent session is properly started before attempting operations. 2. Verify that the agent hasn’t been stopped or closed. 3. Confirm that you are not trying to access agent functionality outside of an active session context. The agent must be in an active running state with a valid activity context for most operations to succeed. Sources: livekit-agents/livekit/agents/voice/agent_activity.py