limited-spring-14213
12/11/2025, 7:51 PMtall-airline-16756
12/11/2025, 7:51 PMtall-airline-16756
12/11/2025, 7:52 PM@server.rtc_session() and the server registers it.
◦ Node: ensure the entry function is exported as the entry property in defineAgent().
• AgentServer request handler not wiring the entrypoint
◦ Confirm your requestFunc / on_request correctly passes or references the entrypoint when accepting the job.
• Process initialization failure
◦ Check worker process startup logs for dependency errors, import failures, wrong file paths, or failures in setup_fnc / prewarm.
• Entrypoint throws immediately
◦ Look for immediate exceptions (import errors, misconfigured resources). Check stderr/worker logs for tracebacks.
• Blocking or hanging calls at start
◦ The entrypoint may reach a blocking await (e.g., ctx.connect()) and hang due to network/permission/room access issues — enable timeouts or log before/after key awaits to verify progress.
• CLI/startup not using framework runner
◦ Ensure the agent is started with cli.run_app() (Python) or cli.runApp() (Node) so the framework dispatches jobs correctly.
Debugging steps (quick)
1. Set worker logging to DEBUG and watch lifecycle logs for process start, job accept, and dispatch messages.
2. Add early logs in your entrypoint (first line) and in requestFunc to confirm whether the function is invoked.
3. Check worker stderr/stdout for exceptions during process init or immediately after job accept.
4. Temporarily simplify the entrypoint to a no-op that logs and exits to confirm dispatch works.
5. Validate prewarm / setup_fnc completes and does not throw or block.
If you want, tell me:
• which language (Python or Node) and
• a minimal snippet of your requestFunc / entrypoint registration and startup command
—I can point to the exact lines to inspect or suggest a minimal repro to run.
Sources: Agent server options | LiveKit docs | Job lifecycle | LiveKit docslimited-spring-14213
12/11/2025, 8:18 PMtall-airline-16756
12/11/2025, 8:18 PMload_threshold), the job will not start.
• Forcing acceptance while overloaded risks process startup failures, resource exhaustion, or degraded/unresponsive agents.
• In LiveKit Cloud, `load_fnc`/`load_threshold` behavior is enforced and cannot be changed, so you can’t bypass capacity checks there.
What to do:
• Monitor agent logs and DEBUG-level lifecycle messages to see whether process spawn fails.
• Track agent load and concurrent process counts; add safeguards in requestFunc (e.g., check current load) instead of unconditionally accepting.
• As a quick test, make requestFunc accept and use a minimal entrypoint that logs immediately and exits to confirm dispatch behavior under different load levels.
If you share which language (Python or Node) and your requestFunc snippet, I can point to exactly where to add a safe capacity check and diagnostic logs.
Sources: Agent server options | LiveKit docs | Deploying to custom environments | LiveKit docslimited-spring-14213
12/11/2025, 8:41 PMtall-airline-16756
12/11/2025, 8:42 PMload_fnc and accessible properties)
1. Define a load_fnc that computes load (0..1) and/or expose whatever metric you need (active jobs, CPU, memory).
2. In request_fnc, call that same function or read the server state to decide.
Example:
from livekit.agents import AgentServer
def compute_load(server) -> float:
# example: scale active jobs to 0..1
return min(len(server.active_jobs) / 10, 1.0)
async def request_fnc(req):
current_load = compute_load(server)
if current_load < 0.7:
await req.accept()
else:
await req.reject()
server = AgentServer(load_fnc=lambda: compute_load(server), load_threshold=0.7)
Node.js (similar pattern)
1. Provide a loadFunc to the AgentServer and call it from your request handler.
Example:
const computeLoad = (server: AgentServer): number => {
return Math.min(server.activeJobs.length / 10, 1.0);
};
const requestFunc = async (req: JobRequest) => {
const currentLoad = computeLoad(server);
if (currentLoad < 0.7) {
await req.accept();
} else {
await req.reject();
}
};
const server = new AgentServer({
loadFunc: () => computeLoad(server),
loadThreshold: 0.7,
requestFunc,
});
Notes and quick tips
• The framework’s default load_fnc uses CPU, but you can use active job count, memory, or any metric.
• Keep load_fnc cheap and deterministic; call it in the request handler rather than running expensive checks.
• Use conservative thresholds and add early logging in request_fnc to observe decisions at runtime.
If you share your language and your current request_fnc snippet, I’ll point to where to read the server state or add a lightweight load check.
Sources: Agent server options | LiveKit docslimited-spring-14213
12/11/2025, 10:17 PMtall-airline-16756
12/11/2025, 10:17 PMload_fnc) and load_threshold. If the agent's load exceeds the threshold (or the agent is otherwise unavailable), the LiveKit server will skip that agent and send the job request to another available agent, so your on_request / requestFunc will not be called on the unavailable worker.
Sources: Agent server options | LiveKit docslimited-spring-14213
12/11/2025, 10:33 PMtall-airline-16756
12/11/2025, 10:33 PM