Traceback (most recent call last): File "/home/r...
# ask-ai
l
Traceback (most recent call last): File "/home/rajadurai/Projects/Eclaim/testing/Dynamic-Agent-builder/.venv/lib/python3.13/site-packages/live kit/agents/utils/log.py", line 17, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/rajadurai/Projects/Eclaim/testing/Dynamic-Agent-builder/.venv/lib/python3.13/site-packages/live kit/agents/voice/agent_activity.py", line 552, in _traceable_on_enter await self._agent.on_enter() File "/home/rajadurai/Projects/Eclaim/testing/Dynamic-Agent-builder/src/orchestrator.py", line 69, in on_enter await self.active_task File "/home/rajadurai/Projects/Eclaim/testing/Dynamic-Agent-builder/.venv/lib/python3.13/site-packages/live kit/agents/voice/agent.py", line 876, in __await_impl return await asyncio.shield(self.__fut) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ livekit.agents.llm.tool_context.ToolError: AgentTask dynamic_task is cancelled
✅ 1
t
Thanks for reaching out, Rajadurai. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m looking into the
AgentTask dynamic_task is cancelled
error you shared. To diagnose whether this is expected behavior or a bug I need a few details from you: • LiveKit package version (output of
pip show livekit
or from pyproject/requirements) and Python version. • The minimal reproducible code (or the relevant excerpt) showing how you create/run the
AgentTask
named
dynamic_task
and where you await or cancel it. Include any use of
asyncio.shield
,
task.cancel()
, timeouts, or wrappers. • Your Agent/Voice agent configuration and the
on_enter
implementation (the function that contains
await self.active_task
). • A short window of full logs (a few minutes before and after the traceback), ideally with debug-level logging for
livekit.agents
. • Whether any component in your system explicitly cancels the task (via
cancel()
), or if you expect the task to run to completion. • Any custom
Tool
or
ToolContext
implementations used by the agent (code or descriptions). • Steps to reproduce the error reliably and the environment it runs in (long-running server, tests, multi-threaded, orchestration that may restart/cleanup tasks). Send those details and I’ll pinpoint whether this is a usage issue (and show how to avoid cancellation) or something that needs deeper investigation. , with interactive elements
l
how to fix it
t
Thanks — I’m sorry you hit that error. To give a precise fix I need a bit more context about how
dynamic_task
is created, awaited, or cancelled. Could you provide the following? • LiveKit package version (
pip show livekit
) and Python version. • The code around where you create/run the
AgentTask
named
dynamic_task
and the
on_enter
method (the function with
await self.active_task
). Paste the minimal reproducible snippet. • Any explicit
cancel()
calls, timeouts, or use of `asyncio.shield`/`asyncio.wait_for` around that task. • Any custom
Tool
or
ToolContext
implementations used by the agent. • Whether this runs in a test, long‑running server, or orchestration that might stop tasks. With those I can show targeted fixes (e.g., avoid premature cancellation, await the task correctly, use
asyncio.shield
properly, or adjust timeouts) and provide a code example. , with interactive elements