helpful-salesclerk-77327
08/04/2025, 4:23 AMtall-airline-16756
08/04/2025, 4:23 AMtall-airline-16756
08/04/2025, 4:23 AMagent_name in the WorkerOptions. This disables automatic dispatch. Example:
if __name__ == "__main__":
cli.run_app(WorkerOptions(
entrypoint_fnc=entrypoint,
agent_name="my-specific-agent" # Disables automatic dispatch
))
2. Implement Conditional Response Logic: Modify the agent's instructions to only respond to specific triggers. Example:
class MyAgent(Agent):
def __init__(self):
super().__init__(
instructions="You are a helpful agent. Only respond when explicitly called.",
stt=deepgram.STT(),
llm=openai.LLM(model="gpt-4o-mini"),
tts=cartesia.TTS(),
vad=silero.VAD.load(),
)
self.waiting_for_trigger = True
async def on_enter(self):
self.session.say("Waiting for trigger...")
3. Set Up Request Handling: Use the request_fnc in WorkerOptions to control when the agent accepts or rejects job requests. Example:
async def handle_request(request: JobRequest):
if request.metadata.get("trigger_condition"):
await request.accept(
name="my-specific-agent",
identity="my-specific-agent-id",
)
else:
await request.reject()
if __name__ == "__main__":
cli.run_app(WorkerOptions(
entrypoint_fnc=entrypoint,
request_fnc=handle_request
))
This setup ensures the agent only responds when explicitly called. Let me know if you need further clarification or additional examples.
Sources: Anatomy of an Agent | LiveKit Docs | Agents telephony integration | LiveKit Docs | examples/voice_agents/toggle_io.py