background_audio = BackgroundAudioPlayer( ...
# ask-ai
b
background_audio = BackgroundAudioPlayer( thinking_sound=[ AudioConfig("/home/ubuntu/agent_tel/Breath_inV2_2.wav", volume=1,probability=0.5), AudioConfig("/home/ubuntu/agent_tel/Breath_inV2.wav", volume=1,probability=0.5), ], ) await background_audio.start(room=ctx.room, agent_session=session) i get {"message": "Error in _play_task\nTraceback (most recent call last):\n File \"/home/ubuntu/.local/lib/python3.12/site-packages/livekit/agents/utils/log.py\", line 16, in async_fn_logs\n return await fn(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/ubuntu/.local/lib/python3.12/site-packages/livekit/agents/voice/background_audio.py\", line 367, in _play_task\n await gen.aclose()\nRuntimeError: aclose(): asynchronous generator is already running", "level": "ERROR", "name": "livekit.agents", "pid": 147421, "job_id": "AJ_Qus3zDTdynMM", "timestamp": "2025-11-10T112532.527048+00:00"}
t
Thanks for reaching out, timothe. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Could you please share a bit more about when this error pops up? For instance, does it happen all the time or just now and then? Also, have you noticed if certain actions or situations seem to bring it on? It would be really helpful to know if you're using any custom tweaks or settings with the BackgroundAudioPlayer too. I’m here to help you get this sorted out! Sources: tests/test_llm.py | livekit-rtc/livekit/rtc/audio_stream.py | Agent speech and audio | LiveKit docs | agents/src/worker.ts
b
it happens when the llm is thinking
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!