I'm building a checklist assistant for tasks where...
# ask-ai
b
I'm building a checklist assistant for tasks where after my task is done -> I'll say this task is done and agent will mark it as done. I understand Siri and Gemini can do this, but this is a business use-case where I have several other business logic working in the backend. Have a few questions regarding the limits to achieve this kind of agent: 1. What is the max time limit an user can stay in a room with a cloud agent without speaking anything? 2. I am using the Gemini Live API. So if 10 users are connected concurrently in 10 rooms, what limits should I check from Google APIs and what limits should i ask them to increase? 3. Can these instructions work with LLMs - "Only process instructions when I call out your name and ask you to do the work?". Example - I will be connected to my agent in a room via Bluetooth continuously. I will also be talking with other people. But when I say "Hey Gemini, mark work 2 as done" and ideally, the agent should process only this sentence.
t
Thanks for reaching out, Aakash. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thank you for your questions! Here are some helpful answers to guide you: 1. Max time limit for staying in a room without speaking: LiveKit doesn’t set a strict global limit for this. However, you can customize the
user_away_timeout
setting (which defaults to 15 seconds) to mark users as "away" after a period of inactivity. Additionally, if you’d like, you can create your own silence detection logic to disconnect users after a certain duration, like 5-10 seconds of silence. This way, you have full control over the experience. 2. Google API limits for Gemini Live API: LiveKit itself doesn’t enforce specific limits for using the Gemini Live API. It’s a great idea to check Google’s API documentation to understand concurrency and rate limits. For your setup with 10 users in 10 rooms, reviewing Google’s quota policies and requesting any necessary increases will help ensure smooth operation. 3. Processing instructions with wake words: While the Gemini Live API doesn’t have built-in wake word detection (like saying "Hey Gemini"), you can definitely implement this on your end. By using a wake word handler, you can filter transcripts and only process those that include the wake word. This can be done by intercepting the STT stream and triggering processing once the wake word is detected. It’s a neat way to make your application more interactive! Please don’t hesitate to reach out if you’d like more details or need help with implementation. I’m here to support you every step of the way! Sources: Events and error handling | LiveKit docs | livekit-agents/livekit/agents/voice/agent.py | Operational Guidance & Best Practices | livekit/livekit_composite | DeepWik... | Agent Testing & CI/CD | livekit/livekit_composite | DeepWiki | agent_extensions/README.md
s
my on_enter is not working during task handoff
t
It looks like the
on_enter
method might not be working during task handoff because the handoff process isn't properly triggering the agent state change. Let’s walk through some steps together to help you troubleshoot and get this sorted out: 1. Verify the Handoff Method: Make sure the handoff uses either
session.update_agent(new_agent)
or returns a new agent instance from a function tool. These are the key ways to trigger the
on_enter
lifecycle hook. 2. Check Agent Activation: Double-check that the new agent has truly become the active agent by looking at
session.agent
right after the handoff. 3. Implement Valid
on_enter
Logic:
Confirm that the
on_enter
method is properly overridden in your agent class and includes the actions you want, like updating instructions or sending a warm welcome message. 4. Avoid Manual Agent Swaps: Try to avoid manually assigning agents outside of LiveKit’s workflow system, since this can stop lifecycle hooks like
on_enter
from running. If you’re still running into issues, it might help to check for any uncaught exceptions during the handoff, or verify that the
on_enter
method is implemented as an async function in your agent class. Please feel free to reach out if you want me to help you dig deeper into this! Sources: Pipeline nodes and hooks | LiveKit docs | Workflows | LiveKit Docs | livekit-agents/livekit/agents/job.py | Building an Automated IVR Menu Caller | LiveKit Docs
s
this is the tool call @function_tool() async def handle_query_task(self, context: RunContext_T) -> str: """ Use this when the caller asks a general FAQ / knowledgebase question. This will run a sub-task to answer the question and then return control to main_agent. """ userdata: UserData = context.userdata # Run the task with the SAME chat_ctx to preserve conversation task = HandleQueryTask( bot_id=self.bot_id, chat_ctx=self.chat_ctx, # <— shared context ) # Await the task result; this yields until the KB question flow is done. # result: bool = await task # logger.info(f"HandleQueryTask finished with result={result}") logger.info(f"Started HandleQueryTask from main_agent tool {task}") # At this point, control is back in main_agent. chat_ctx is already shared, # so you don't need to manually merge anything. return "Knowledgebase task started." # if result: # return "Caller question was answered by knowledgebase task." # else: # return "Knowledgebase task could not fully answer the caller’s question." and my task class HandleQueryTask(AgentTask[bool]): """ Task to answer caller questions from the knowledgebase. - If answer is not available, sends a summary email to the team. - Returns True if handled, False if email failed or similar. """ def __init__(self, bot_id=None, chat_ctx=None): self.bot_id = bot_id updated_prompt = handle_query_agent_prompt.format( bot_id=bot_id, ) logger.info(f"chat_ctx: {chat_ctx}") logger.info(f"HandleQueryTask prompt: {updated_prompt}") # IMPORTANT: pass chat_ctx from the calling agent so context is preserved super().__init__( instructions=updated_prompt, chat_ctx=chat_ctx, ) async def on_enter(self) -> None: """ Start the KB interaction: generate a single reply using the KB prompt, then immediately complete the task. """ logger.info("HandleQueryTask.on_enter: generating KB reply") await self.session.generate_reply( tool_choice="auto", # let it use send_summary_query_email if needed allow_interruptions=False, instructions=""" Use the knowledgebase to answer the caller's question. If you cannot find an answer, use the send_summary_query_email tool to send a summary email to the support team. After sending the email, inform the caller that their question could not be answered but that the team will follow up via email. """, ) # After one turn, we're done – go back to main_agent logger.info("HandleQueryTask.on_enter: completing task") self.complete(True)
t
I'm here to help you with the issue of
on_enter
not triggering in your custom
AgentTask
implementation. This could be happening for a few reasons, so let's walk through them together: 1. Agent is not becoming active: Please double-check that your agent is properly set as the active agent in the session. Remember, the
on_enter
method only fires when the agent actually becomes active. 2. Session not started correctly: Make sure the session is initialized and started properly using
AgentSession.start()
. If the session doesn’t start as expected,
on_enter
won’t run. 3. Incorrect method override: It’s important that
on_enter
is correctly overridden in your agent class as an
async
method. Sometimes a small issue in the method definition can stop it from being called. 4. Handoff or workflow issues: If you’re using workflows to switch agents, please confirm that the handoff mechanism is activating your agent properly. The
on_enter
lifecycle hook depends on the session’s state update logic. 5. Execution context restrictions: Ensure that all operations within
on_enter
are awaited properly and don’t interfere with the agent’s state management. 6. Timing in multi-agent workflows: In multi-stage flows, it’s key that the previous agent’s workflow correctly returns the next agent instance. Any hiccups in the handoff can prevent
on_enter
from triggering. To help you troubleshoot further, here are some steps you might try: • Add some logging right at the start of
on_enter
to see if it’s being called at all. • Check that
session.current_agent
matches your agent instance after the handoff. • Verify that your agent is instantiated correctly with all the necessary parameters. If you’d like, I’m more than happy to help you review your workflow or dig into debugging together. Just let me know! Sources: Building an Automated IVR Menu Caller | LiveKit Docs | Pipeline nodes and hooks | LiveKit docs | livekit-agents/livekit/agents/voice/agent_activity.py | complex-agents/ivr-agent/README.md