Dispatcher Issue

Hi Team,

I am facing an issue with the LiveKit agent worker and would appreciate your guidance.

Case 1

When I dispatch an agent to join a room, sometimes it works correctly, but other times only the dispatch is created while the agent worker does not respond and does not start transcribing data.

In those cases, the real-time meeting continues, but the agent never starts processing, which causes me to lose the meeting data.

Case 2

To resolve this issue, I implemented a Redis-based approach.

What I did:

  • During dispatch, I check a Redis flag.

  • If the flag is not equal to 1, I retry the dispatch and create a new dispatch repeatedly.

  • On the agent worker side, whenever the worker executes successfully or starts responding, I set the Redis flag to 1.

This implementation helped me verify whether the worker actually started and allowed me to dispatch accordingly.

However, now I am facing another issue: sometimes the agent suddenly leaves the meeting even though the session is still active and was not closed.

Case 3

For a more permanent solution, I contacted LiveKit AI support. They suggested replacing the Redis approach with job_status from LiveKit.

I updated both my dispatcher and agent worker code accordingly.

What I observed:

  • Sometimes after dispatching, I receive job_status = 2, which indicates the agent is running correctly.

  • However, most of the time I receive job_status = 1.

When the status remains 1, the agent does not start the job, and because of that I lose the meeting conversation data.

Example logs:

Room ensured: 0u4r9n
Found existing dispatch: AD_8Chk8zceLc7t
Creating NEW dispatch for room 0u4r9n
Dispatch created: AD_X2XvFEEeMZeL
Poll 5 → Status: 1

Could you please help me understand what I might be doing wrong and suggest the correct permanent solution for handling this issue?

Thank you.

Hi, I would start by trying to solve the underlying issue (your case 1) since it feels like your cases 2 and 3 were workarounds for the issue where the agent was not successfully dispatching.

The place to start is your agent logs, do you see any clues in there why the agent is not being dispatched?

If you can provide a session ID (starts with RM_) I can take a look at a failing session and see if anything shows in the server logs.

I notice these are self-hosted agents, so I would also check that you have enough capacity on the machines hosting the agents:

@Ajaz_Ali1, The JobStatus enum semantics might be inverted in your reading. From livekit/protocol/protobufs/livekit_agent.proto:

  JS_PENDING = 0
  JS_RUNNING = 1
  JS_SUCCESS = 2
  JS_FAILED = 3

Your logs show Status: 1, which is JS_RUNNING, not “agent didn’t start.” Status: 2 is JS_SUCCESS (job completed). So when you see Status: 1 repeatedly, the dispatch is running on the agent worker side. The problem isn’t dispatch failing; it’s the running worker not transcribing once it’s in.

That shifts where to look. the above links, agent worker logs for a session showing Status: 1 will reveal whether the worker is alive but stalled (plugin init failure, audio subscription issues, or exceptions in session.start() / on_enter that don’t surface to the dispatcher) rather than the dispatch itself failing.