I have never seen this error before, what doe s it...
# ask-ai
r
I have never seen this error before, what doe s it mean? the call didn’t go thru CRITICAL: AgentInitializationError in phone-worker 🚨 AgentInitializationError — phone-worker Environment: production From Number:
<tel:+17037312463|+17037312463>
To Number:
<tel:+17036868627|+17036868627>
Agent ID:
9a16fbf4-2778-4718-9d96-493dd0bcc6da
Room:
inbound-call-_+17037312463_33R9k5dhBre9
Conversation ID:
aa0c8b37-ecae-45e9-9e97-8c1a7313328a
Error:
Copy code
room error engine: connection error: engine is closed
Stack Trace:
Copy code
Traceback (most recent call last):
  File "/app/app/livekit_worker.py", line 2232, in entry
    await agent.initialize(ctx)
  File "/app/app/agents/standard_agent.py", line 674, in initialize
    await self._background_audio.start(ctx.room, self.session)
  File "/app/app/pipeline/audio_background.py", line 117, in start
    return await self._start_ambient_mode(room, session)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/app/pipeline/audio_background.py", line 145, in _start_ambient_mode
    await self._player.start(
  File "/usr/local/lib/python3.11/site-packages/livekit/agents/voice/background_audio.py", line 262, in start
    await self._publish_track()
  File "/usr/local/lib/python3.11/site-packages/livekit/agents/voice/background_audio.py", line 394, in _publish_track
    self.publication = await self._room.local_participant.publish_track(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/livekit/rtc/participant.py", line 759, in publish_track
    raise PublishTrackError(cb.publish_track.error)
livekit.rtc.participant.PublishTrackError: room error engine: connection error: engine is closed
May 27, 2026 at 142734 UTC
t
Thanks for reaching out, luisa. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I see you’re asking what the "AgentInitializationError in phone-worker" means for the failed call. I looked at the stack trace and room/agent info you provided. What happened (short): the agent failed while starting background audio because the WebRTC engine for the room was already closed when it attempted to publish a track. The immediate error from the SDK is: "room error engine: connection error: engine is closed" which surfaced as a PublishTrackError and bubbled up to AgentInitializationError. Likely causes to check next: • The WebRTC/signaling connection closed before background audio publish completed (network flare, signaling failure, or worker restarted). • A race where the agent tried to publish background audio before the room/engine was fully connected. • Resource or startup delay on the worker causing the engine to time out or be closed. Next troubleshooting steps you can try: 1. Check room lifecycle around the timestamp (May 27, 2026 142734 UTC): ◦ Was the room created and stable before the agent initialized? ◦ Any server restarts, worker crashes, or network interruptions at that time? 1. Inspect agent/worker logs for earlier connection errors or disconnect reasons for that room/agent ID (
9a16fbf4-...
) and room
inbound-call-_+17037312463_33R9k5dhBre9
. 2. Reproduce with logging around background audio publish: ◦ Log connection-ready state before calling
publish_track()
. ◦ Add a short delay/retry before publishing to rule out a race. 1. If this is intermittent, monitor for patterns (same agent ID, same worker, same time window) to isolate network vs startup timing. 2. If you want an immediate workaround, consider skipping background-audio publish during initialization to confirm the rest of the agent can initialize. If you’d like, I can: • Help interpret related logs if you paste the connection / signaling lines around the timestamp. • Suggest a small retry wrapper or sample code to delay/retry
publish_track()
to avoid the race. Which would you prefer? Sources: The ReAct Pattern for Voice Agents and How AI Agents Think, Act, and Respon... | Background audio | LiveKit Documentation | Understanding the STATE_MISMATCH Disconnect Reason, with interactive elements