Im using Tasks to control the flow of the voice ai...
# ask-ai
d
Im using Tasks to control the flow of the voice ai, is that the best method to do this?
Copy code
result = await functionCall
if result:
another_result = await anotherFunction
if another_result:
is that the best way??
t
Thanks for reaching out, Billy. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I understand you're exploring how to control the flow of a voice AI in LiveKit, and I’m here to help clarify things for you. Using Tasks can work for certain situations—they’re great for discrete, self-contained workflows like gathering specific pieces of data or handling modular sub-tasks. However, since they’re experimental, Python-only, and not really built for long-term or complex session control, they might not be the best fit for every scenario. For workflows that need to be persistent or stateful, Agents are usually the better choice. They offer more stable, long-term control, support both Python and Node.js, and handle state management more effectively. This makes them perfect for multi-phase conversations or when you need dynamic routing between different personas. If you’d like, feel free to share more about your specific use case. I’d be happy to guide you toward the approach that will work best for you. Sources: Workflows | LiveKit Docs | Workflows | LiveKit Docs | Building Multi-Agent Architectures with LiveKit Agents
d
Ive tried agents and it the llm never flows perfect even with 0.1 temperature setting. eg. step1 verify caller step2 send code step 3 verify code step 4 ask question step 5 gather user input step 6 answer question for some the agent doesnt always follow the flow and using tasks does it perfect... so when do i use Tasks vs Agents
t
Thank you for sharing your example! Tasks really shine when it comes to structured, step-by-step workflows like verifying a caller, sending a code, and then verifying that code. They’re designed to be reliable and focused, taking temporary control to complete specific objectives and returning clear, structured results. This makes them especially great for those critical data-gathering moments where accuracy is so important. Agents, on the other hand, offer more flexibility. They’re wonderful for managing broader, multi-phase conversations or smoothly switching between different workflows. While they rely on LLMs and can sometimes wander from strict flows in complex situations, their adaptability is a real strength. For your situation, a blend of both might work beautifully. You could use Tasks for those essential, structured steps like verifying the code, and let an Agent take care of the overall flow and transitions. This way, you get the best of both worlds—reliability where it counts and flexibility to handle the bigger picture. Sources: Workflows | LiveKit Docs | Workflows | LiveKit Docs | README.md | Building the all-in-one platform for voice AI agents | flows/multi_stage_flow.py
1
d
Is there a way to make the voice ai sound serious or stern during part of the conversation. for example if a user repeats the requests and it cannot be fulfilled.
t
I’m glad you asked about making the voice AI sound serious or stern during certain parts of a conversation! Depending on your setup, here are some friendly ways to achieve that: • TTS Instructions: If you’re working with OpenAI or Azure OpenAI TTS, you can gently guide the voice by setting tone instructions like "Speak in a stern, authoritative tone with low pitch and measured pace." This really helps the voice convey the right emotion. • Structured LLM Output: Another approach is to have the LLM provide both the response text and voice instructions. For example, it might include "Speak sternly" along with the message, so the TTS adjusts just right. • Voice Selection: Picking a voice that naturally sounds serious, like "ash" or "verse" in OpenAI TTS, or "Charon" in Gemini TTS, can make a big difference. • LMNT TTS: You can also tweak parameters like temperature (around 0.3) to keep the tone consistent and serious by reducing randomness. If you’d like, I’d be happy to walk you through any of these methods in more detail or provide some examples. Just let me know what works best for you! Sources: OpenAI TTS integration guide | LiveKit Docs | OpenAI TTS integration guide | LiveKit Docs | examples/voice_agents/structured_output.py | Azure OpenAI TTS integration guide | LiveKit Docs | web/src/data/presets.ts