What is the difference between AgentServer and Age...
# ask-ai
c
What is the difference between AgentServer and AgentSession?
✅ 1
t
Thanks for reaching out, Abhishek. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — good question. Here's a concise explanation of the difference between AgentServer and AgentSession. • AgentServer ◦ The long-running service/process that registers with LiveKit to accept jobs. ◦ Manages job dispatch, load balancing, health checks, and lifecycle for agent jobs. ◦ Runs continuously (one instance per container) and spawns/controls worker processes for each job. • AgentSession ◦ A single job instance created by the AgentServer for one room/interaction. ◦ Orchestrates the conversation pipeline (STT, LLM, TTS, VAD, turn detection), emits session events, and progresses through lifecycle states (Initializing → Starting → Running → Closing). ◦ Lives only for the duration of that room/participant session; it runs inside a JobProcess managed by the AgentServer. In short: AgentServer provides the infrastructure and management; AgentSession is the per-conversation job that runs inside that infrastructure. Sources: Server options | LiveKit Documentation | Server lifecycle | LiveKit Documentation | Agent server overview | LiveKit Documentation | Agent session | LiveKit Documentation, with interactive elements
c
today i use WorkerOptions to set the configuration like this
Copy code
worker_options: dict[str, Any] = {
    "entrypoint_fnc": entrypoint,
    "prewarm_fnc": prewarm,
    "load_fnc": compute_worker_load,
    "num_idle_processes": 2,  # keep two warmed processes ready
    "agent_name": DEFAULT_AGENT_NAME,
    "shutdown_process_timeout": 60,
}
if os.getenv("WORKER_LOAD_THRESHOLD"):
    worker_options["load_threshold"] = _worker_load_threshold()

options = WorkerOptions(**worker_options)
agents.cli.run_app(options)
Does agentserver replace worker options?
t
Thanks — I’m responding to your question about whether AgentServer replaces WorkerOptions. Yes. AgentServer (and ServerOptions in Node) replaces the older Python WorkerOptions pattern. The settings you currently pass in WorkerOptions map to AgentServer configuration and decorators: •
entrypoint_fnc
→ use
@server.rtc_session(agent_name=...)
on your entrypoint •
prewarm_fnc
→ assign to
server.setup_fnc
•
load_fnc
and
load_threshold
→ pass to
AgentServer(load_fnc=..., load_threshold=...)
•
num_idle_processes
→ handled by the server’s process management/prewarm behavior •
agent_name
→ set on the
@server.rtc_session(...)
decorator •
shutdown_process_timeout
→ use
drain_timeout
on
AgentServer
Example migration:
Copy code
server = AgentServer(
    load_fnc=compute_worker_load,
    load_threshold=_worker_load_threshold(),
    drain_timeout=60,
)

server.setup_fnc = prewarm

@server.rtc_session(agent_name=DEFAULT_AGENT_NAME)
async def entrypoint(ctx: JobContext):
    ...
If you want, tell me which specific WorkerOptions you use and I’ll give the exact AgentServer equivalent for each. Sources: Server options | LiveKit Documentation, with interactive elements