Skip to content

Conversation

@kstonekuan
Copy link
Contributor

Summary

This PR fixes a bug where the ws_url parameter from WorkerOptions was not being passed to the AgentServer constructor in AgentServer.from_server_options(). This caused runtime errors when ws_url was provided in WorkerOptions but not set in the environment variables.

Changes

  • Updated AgentServer.from_server_options in livekit/agents/worker.py to explicitly pass ws_url=options.ws_url to the AgentServer constructor.

Testing

  • Ran linting (ruff check), formatting (ruff format), and type checking (mypy) as per CONTRIBUTING.md.
  • Ran the following script to verify the fix:
import os
import asyncio
from livekit.agents import AgentServer, WorkerOptions, JobContext

async def test_ws_url_propagation():
    # Clear environment variables to ensure we're testing WorkerOptions
    for key in ['LIVEKIT_URL', 'LIVEKIT_API_KEY', 'LIVEKIT_API_SECRET']:
        os.environ.pop(key, None)

    async def entrypoint(ctx: JobContext):
        pass

    worker_options = WorkerOptions(
        entrypoint_fnc=entrypoint,
        ws_url='wss://test-server.livekit.cloud',
        api_key='test-api-key',
        api_secret='test-api-secret',
    )

    # This should work without environment variables
    server = AgentServer.from_server_options(worker_options)
    
    # Verify that the ws_url was correctly set on the server instance
    assert server._ws_url == 'wss://test-server.livekit.cloud'
    print("✅ ws_url propagated correctly!")

if __name__ == '__main__':
    asyncio.run(test_ws_url_propagation())

@CLAassistant
Copy link

CLAassistant commented Nov 21, 2025

CLA assistant check
All committers have signed the CLA.

@theomonnom
Copy link
Member

Thanks!

@theomonnom theomonnom merged commit 9a2d16f into livekit:main Nov 24, 2025
8 of 9 checks passed
@kstonekuan kstonekuan deleted the fix/ws-url-propagation branch November 25, 2025 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants