alert-wire-7024
12/23/2025, 10:36 AMWorkerOptions or use the @server.rtc_session() decorator?tall-airline-16756
12/23/2025, 10:36 AMtall-airline-16756
12/23/2025, 10:36 AM@server.rtc_session() decorator to define the entrypoint.
server = AgentServer()
@server.rtc_session()
async def entrypoint(ctx: JobContext):
await ctx.connect()
• If you’re not using AgentServer and are running a standalone worker, pass your entrypoint into WorkerOptions(entrypoint_fnc=...).
async def entrypoint(ctx: JobContext):
await ctx.connect()
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
Do not use both simultaneously. Use AgentServer (decorator) when you need server-level lifecycle hooks and customization; use WorkerOptions for a simpler standalone worker.
Do you want help converting your current setup to one of these patterns?
Sources: Agent server options | LiveKit docs | Building an Automated IVR Menu Caller | LiveKit docsalert-wire-7024
12/23/2025, 10:36 AMtall-airline-16756
12/23/2025, 10:37 AM@server.rtc_session() (AgentServer): for running an agent as a server with lifecycle hooks and richer server-level control.
• WorkerOptions(entrypoint_fnc=...) (standalone worker): for running a single worker process with a direct entrypoint, simpler/lighter weight.
Usage pattern
• AgentServer + decorator:
◦ You create an AgentServer() instance.
◦ Decorate the entrypoint with @server.rtc_session() so the server manages sessions, routing, and lifecycle.
◦ Server provides hooks like setup_fnc, on_request, and other server-level configuration.
• WorkerOptions:
◦ You write an async entrypoint(ctx: JobContext) and pass it to WorkerOptions(entrypoint_fnc=entrypoint).
◦ Run via the CLI runner for a straightforward worker process without server scaffolding.
Lifecycle & features
• AgentServer:
◦ More control over startup, shutdown, request handling, and additional server hooks.
◦ Better for complex agents, multi-endpoint handling, or when you need centralized configuration.
• WorkerOptions:
◦ Minimal lifecycle management—just run the worker entrypoint.
◦ Ideal for lightweight, single-purpose workers or simple deployments.
When to pick which
• Choose AgentServer + @server.rtc_session() when you need server-level features, multiple hooks, or a more configurable runtime.
• Choose WorkerOptions(entrypoint_fnc=...) when you want a simple, standalone worker with minimal boilerplate.
You shouldn’t use both at once. Want to show me your current code so I can recommend which fits it best?alert-wire-7024
12/23/2025, 10:52 AMtall-airline-16756
12/23/2025, 10:53 AMmcp_servers parameter (e.g., AgentSession(mcp_servers=[mcp.MCPServerHTTP(...)] )). Tools from MCP servers are loaded at startup and cannot be added or removed at runtime.
If you need dynamic tool availability, you can either:
• Recreate/reinitialize the session with the updated mcp_servers, or
• Load tools programmatically by other means (not via adding MCP servers at runtime).
Do you want help with reinitializing the session or an alternative approach to load tools dynamically?
Sources: Tool definition and use | LiveKit docs