Skip to content

Agent Stops Responding After 2–3 Concurrent Sessions on Self-Hosted LiveKit ServerΒ #4331

@w3villa-yash-dubey

Description

@w3villa-yash-dubey

Problem Description

I am facing an issue while using a self-hosted LiveKit server deployed using docker. When I run multiple rooms with the same agent (for example, Room 1 β†’ Agent + User 1, Room 2 β†’ Agent + User 2, etc.), then agent stops speaking for some users after 2–3 concurrent rooms with same agent. According to the documentation, one agent should be able to run multiple concurrent sessions. Why is this happening ? Please help.

==========Agent dispatch logic(written in node.js backend) ======
const agentName = process.env.INTERVIEW_AGENT_NAME || "interview_agent";

	at.roomConfig = new RoomConfiguration({
		agents: [
			new RoomAgentDispatch({
				agentName: agentName
			})
		]
	});
	
let token = await at.toJwt();

=========Agent worker options==============

if name == "main":

try:
    agents.cli.run_app(agents.WorkerOptions(
        port=8081,
        entrypoint_fnc=entrypoint,
        agent_name=agent_name,
        ws_url=os.getenv("LIVEKIT_URL"),
        api_key=os.getenv("LIVEKIT_API_KEY"),
        api_secret=os.getenv("LIVEKIT_API_SECRET"),
        multiprocessing_context="spawn",
        drain_timeout=DRAIN_TIMEOUT,
        initialize_process_timeout=INITIALIZE_PROCESS_TIMEOUT,
        num_idle_processes=12,
    ))
except Exception as e:
    send_error_notification(
        e,
        "Failed to start agent worker",
        session_id=None,
        origin="agent.py",
        company_id=None,  # No room-specific company_id at worker startup
        candidate_name='not fetched yet',
    )
    raise

========This is my agent session code snippet===========

Create voice pipeline components (pass preloaded VAD for reduced latency)

try:
    stt, llm, tts, vad = create_voice_components(api_keys, preloaded_vad=preloaded_vad)
except Exception as e:
    logger.error(f"Failed to create components: {str(e)}")
    notify(e, "Failed to create voice components")
    raise
try:
    session = AgentSession(
        stt=stt,
        llm=llm,
        tts=tts,
        vad=vad,
        turn_detection="vad",  # Use VAD-based turn detection for better pause handling
        min_endpointing_delay=3.0,  # Increased to allow more thinking time
        max_endpointing_delay=3.0,  # Increased to prevent premature responses
        allow_interruptions=True,   # Enable interruptions to detect user speech
        min_interruption_duration=0.5,  # Minimum speech duration to trigger detection (500ms)
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions