aclose(): asynchronous generator is already running
Bug Description
{"message": "Error in _realtime_generation_task\nTraceback (most recent call last):\n File "/usr/local/lib/python3.12/site-packages/livekit/agents/utils/log.py", line 17, in async_fn_logs\n return await fn(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/usr/local/lib/python3.12/site-packages/livekit/agents/voice/agent_activity.py", line 2313, in _realtime_generation_task\n await self._realtime_generation_task_impl(\n File "/usr/local/lib/python3.12/site-packages/livekit/agents/voice/agent_activity.py", line 2630, in _realtime_generation_task_impl\n await tee.aclose()\n File "/usr/local/lib/python3.12/site-packages/livekit/agents/utils/aio/itertools.py", line 95, in aclose\n await child.aclose()\nRuntimeError: aclose(): asynchronous generator is already running", "level": "ERROR", "name": "livekit.agents", "exc_info": "Traceback (most recent call last):\n File "/usr/local/lib/python3.12/site-packages/livekit/agents/utils/log.py", line 17, in async_fn_logs\n return await fn(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/usr/local/lib/python3.12/site-packages/livekit/agents/voice/agent_activity.py", line 2313, in _realtime_generation_task\n await self._realtime_generation_task_impl(\n File "/usr/local/lib/python3.12/site-packages/livekit/agents/voice/agent_activity.py", line 2630, in _realtime_generation_task_impl\n await tee.aclose()\n File "/usr/local/lib/python3.12/site-packages/livekit/agents/utils/aio/itertools.py", line 95, in aclose\n await child.aclose()\nRuntimeError: aclose(): asynchronous generator is already running", "pid": 43, "job_id": "AJ_mrX5Exn28LmP", "room_id": "RM_rwjpKAdqjVCd", "timestamp": "2026-02-08T15:53:53.174778+00:00"}
Expected Behavior
Google TTS should work reliably with Azure RealtimeModel like other TTS providers.
Reproduction Steps
agent = AgentSession(
llm=openai.realtime.RealtimeModel.with_azure(
azure_deployment=os.getenv("AZURE_OPENAI_DEPLOYMENT"), azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
api_key=os.getenv("AZURE_OPENAI_API_KEY"), api_version="2025-04-01-preview",
turn_detection=turn_detection_config,
input_audio_transcription=InputAudioTranscription(model="gpt-4o-transcribe", language="te"),
modalities=["text"]
),
tts=google.TTS(
voice_name="te-IN-Chirp3-HD-Erinome",
language="te-IN",
gender="female",
credentials_file=os.getenv("GOOGLE_CREDENTIALS_PATH"),
use_streaming=True,
enable_ssml=False,
audio_encoding=texttospeech.AudioEncoding.LINEAR16 ),
)
Operating System
Windows11
Models Used
Azure-OpenAI , Google TTS
Package Versions
livekit-agents[openai]~=1.0
livekit-agents[google]~=1.3
livekit-plugins-openai
Session/Room/Call IDs
No response
Proposed Solution
Additional Context
No response
Screenshots and Recordings
No response