agents icon indicating copy to clipboard operation
agents copied to clipboard

asyncio error when using function calling

Open lhylton opened this issue 1 year ago • 0 comments

Hello! My agent uses function calling and I frequently get this error

I'm using async def for an ai_callable function with a voice agent where it makes a function call based on what the user said and then responds based on what the user said + instructions received from the tool call. It seems like in the pattern of receive speech > process speech > call function > synthesize speech that some task is being destroyed incorrectly.

Any guidance would be much appreciated!

Sometimes there is minimal impact of the error and other times it causes the agent to freeze mid sentence and wait for the user's response unexpectedly

2024-09-16 15:15:28,593 - ERROR asyncio - Task was destroyed but it is pending! task: <Task pending name='Task-591' coro=<TTSSegmentsForwarder._main_task() running at /Users/lydiahylton/Documents/agent-service/.venv/lib/python3.12/site-packages/livekit/agents/utils/log.py:16> wait_for=<Future pending cb=[Task.task_wakeup()]>> {"pid": 23871, "job_id": "AJ_tuoT3Ti2Fq6B"} 2024-09-16 15:15:28,593 - ERROR asyncio - Task was destroyed but it is pending! task: <Task pending name='Task-593' coro=<TTSSegmentsForwarder._main_task.._forward_task() running at /Users/lydiahylton/Documents/agent-service/.venv/lib/python3.12/site-packages/livekit/agents/utils/log.py:16> wait_for=<Future pending cb=[Task.task_wakeup()]>> {"pid": 23871, "job_id": "AJ_tuoT3Ti2Fq6B"} 2024-09-16 15:15:28,593 - ERROR asyncio - Task was destroyed but it is pending! task: <Task pending name='Task-766' coro=<TTSSegmentsForwarder._main_task() running at /Users/lydiahylton/Documents/agent-service/.venv/lib/python3.12/site-packages/livekit/agents/utils/log.py:16> wait_for=<Future pending cb=[Task.task_wakeup()]>> {"pid": 23871, "job_id": "AJ_tuoT3Ti2Fq6B"} 2024-09-16 15:15:28,593 - ERROR asyncio - Task was destroyed but it is pending! task: <Task pending name='Task-768' coro=<TTSSegmentsForwarder._main_task.._forward_task() running at /Users/lydiahylton/Documents/agent-service/.venv/lib/python3.12/site-packages/livekit/agents/utils/log.py:16> wait_for=<Future pending cb=[Task.task_wakeup()]>> {"pid": 23871, "job_id": "AJ_tuoT3Ti2Fq6B"}

lhylton avatar Sep 16 '24 22:09 lhylton