brave-island-45242
07/30/2025, 3:15 PMtall-airline-16756
07/30/2025, 3:15 PMtall-airline-16756
07/30/2025, 3:17 PMagent_name parameter in WorkerOptions to enable explicit dispatch. This allows you to specify the agent(s) to be dispatched in the end-user's token or use the AgentDispatch.createDispatch API. For example:
opts = WorkerOptions(
entrypoint_fnc=entrypoint,
agent_name="my-priority-agent" # Enable explicit dispatch
)
• Request Handler for Job Control: Use the request_fnc parameter to control which jobs a worker accepts. You can implement prioritization logic to accept or reject jobs based on your criteria. For example:
async def request_fnc(req: JobRequest):
# Add your prioritization logic here
await req.accept(
name="agent",
identity="identity",
attributes={"myagent": "rocks"},
)
# or reject it
# await req.reject()
opts = WorkerOptions(
entrypoint_fnc=entrypoint,
request_fnc=request_fnc
)
• Load-Based Job Management: Control job acceptance through load functions. The load_fnc and load_threshold parameters can limit the number of concurrent jobs a worker accepts. For example:
from livekit.agents import Worker, WorkerOptions
def compute_load(worker: Worker) -> float:
return min(len(worker.active_jobs) / 10, 1.0)
opts = WorkerOptions(
load_fnc=compute_load,
load_threshold=0.9,
)
These methods allow you to prioritize specific worker entrypoints by controlling job dispatch and acceptance. Let me know if you need further clarification or assistance with implementation.
Sources: Worker options | LiveKit Docs