agreeable-forest-33528
12/14/2025, 7:44 AM2025-12-14 07:41:41,016 - ERROR livekit.agents - Error in _realtime_reply_task
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/livekit/agents/utils/log.py", line 16, in async_fn_logs
return await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/livekit/agents/voice/agent_activity.py", line 2169, in _realtime_reply_task
generation_ev = await self._rt_session.generate_reply(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
livekit.agents.llm.realtime.RealtimeError: generate_reply timed out waiting for generation_created event.
{"level": "ERROR", "name": "livekit.agents", "message": "Error in _realtime_reply_task", "exc_info": "Traceback (most recent call last):\n File \"/usr/local/lib/python3.12/site-packages/livekit/agents/utils/log.py\", l
ine 16, 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 2169, in _realtime_re
ply_task\n generation_ev = await self._rt_session.generate_reply(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nlivekit.agents.llm.realtime.RealtimeError: generate_reply timed out waiting for generatio
n_created event.", "timestamp": "2025-12-14T07:41:41.016114+00:00"}tall-airline-16756
12/14/2025, 7:44 AMagreeable-forest-33528
12/14/2025, 7:44 AMtall-airline-16756
12/14/2025, 7:44 AM_realtime_reply_task. I can help troubleshoot. A few quick questions and steps will narrow this down:
Questions
1. Did this happen once or repeatedly? If repeated, how often (every request, intermittent)?
2. Which Realtime model/provider are you using (e.g., OpenAI Realtime)?
3. Any recent changes (API key rotation, network, model param changes)?
4. Can you share relevant environment details: agent version, deployment (local / container / cloud), and network conditions (behind proxy, NAT, firewall)?
5. Do other realtime LLM calls succeed, or is this specific to generate_reply?
Immediate checks you can run
• Verify network connectivity from the agent host to the realtime provider (ping/traceroute, and ensure websockets allowed).
• Confirm API key is valid and not rate-limited by the provider.
• Check provider status/health page for slowdowns or incidents.
• Inspect agent logs around the error for websocket disconnects or retries (look for connection/open/close events).
• If your code/repo exposes a timeout setting for generate_reply or the RealtimeSession, try increasing it or add retries with exponential backoff.
If you can share the answers to the questions above plus a short log excerpt (connection events ±30s around the error), I’ll suggest targeted next steps (config changes, timeout tuning, or specific log lines to watch).
Sources: examples/voice_agents | livekit/livekit_composite | DeepWiki | Agents v0.x migration guide - Node.js | LiveKit Docs | Voice AI quickstart | LiveKit docstall-airline-16756
12/14/2025, 7:44 AM_realtime_reply_task where generate_reply waited for a generation_created event and never received it, and you shared the async call that triggers generate_reply. I can help troubleshoot.
Quick actionable steps to try now
• Add retry with backoff around generate_reply in case of transient provider/network hiccups.
• Catch the specific RealtimeError (if available) and log the full exception and any session/request IDs so you can correlate with provider logs.
• Increase any configurable timeout if your RealtimeSession or client exposes one (or add a custom longer wait) to tolerate slower provider response.
• Verify network and provider status during failures (packet loss, WebSocket drops, rate limits).
• Ensure API keys and model parameters used by your RealtimeModel are valid and not being rate-limited.
Suggested minimal code changes 1) Add retries + better logging:
import asyncio
from asyncio import TimeoutError
async def send_greeting():
await asyncio.sleep(1.0)
if not self.session:
return
max_retries = 3
for attempt in range(1, max_retries + 1):
try:
await self.session.generate_reply(user_input="hello")
logger.info("✅ Greeting sent")
return
except Exception as e:
logger.warning(f"Greeting attempt {attempt} failed: {e}")
if attempt == max_retries:
logger.debug("Greeting failed after retries", exc_info=True)
else:
await asyncio.sleep(2 ** attempt) # exponential backoff
2) If you can, catch the Realtime-specific error to distinguish timeouts:
from livekit.agents.llm.realtime import RealtimeError
# inside retry loop
except RealtimeError as e:
logger.warning(f"Realtime timeout/event error: {e}")
# optionally increase backoff or mark session for reconnect
Diagnostics to collect if problem persists
• Full exception stack trace and timestamp (you already have this).
• Whether the error is intermittent or reproducible every attempt.
• Any websocket disconnect/reconnect events from the RealtimeSession logs.
• Provider-side request IDs or correlation IDs (if the client surfaces them).
• Network metrics/packet loss between your agent and the provider at failure times.
Next question to narrow this down
• Is this intermittent or reproducible every time you call generate_reply?
• Which Realtime model/provider are you using (e.g., OpenAI Realtime)?
• Do you see any WebSocket disconnects or other errors in the session logs around the same timestamps?
Tell me the answers and any additional logs you can share and I’ll suggest the next concrete steps.agreeable-forest-33528
12/14/2025, 7:45 AMtall-airline-16756
12/14/2025, 7:46 AMgenerate_reply?
• Check for any WebSocket disconnects/reconnects in your RealtimeSession logs around the same timestamps.
• Confirm your API key is valid and not being rate-limited by the provider during failures.
• Verify network stability (packet loss, high latency) between your agent host and the provider.
Gemini-specific troubleshooting steps
• Provider-side delays can be more common with preview or high-capacity models; try increasing the wait time before failing (use a longer timeout or an explicit retry/backoff).
• If you can, send the same request at lower audio or prompt complexity to see if it reliably starts a generation (helps isolate model-side performance).
• Collect any provider correlation/request IDs exposed by the client and check the provider status/metrics for the same timestamps.
Concrete next actions (apply in this order)
1. Add retries with exponential backoff around generate_reply (keep existing logging). Retry 2–3 times before failing.
2. Log full session state and any WebSocket close codes when the error occurs.
3. Temporarily increase the timeout waiting for generation_created (or add a custom wait) to confirm whether the model is just slow to start.
4. If intermittent, capture one full failure with timestamps + session/request IDs and the surrounding WebSocket events.
Two quick diagnostic questions
• Does this happen every time or only occasionally?
• Do your RealtimeSession logs show WebSocket disconnects or non-200 responses near the error timestamp?
Tell me the answers and one sample failure log (including any WS close codes and timestamps) and I’ll propose the exact code changes and logging to add next.