proud-lawyer-39815
03/27/2026, 5:42 AMtall-airline-16756
03/27/2026, 5:42 AMtall-airline-16756
03/27/2026, 5:43 AMsession.userdata (or equivalent) so you don’t rely on TaskGroup merging behavior.
• Production-ready: TaskGroup is marked experimental and its API could change; tools + loop are a more stable, explicit pattern for production workloads.
When TaskGroup might still make sense
• Short surveys (a handful of questions) where you want clearly separated tasks, built-in regression/navigation, and automatic merging of task contexts.
• Prototyping where TaskGroup’s ordering/regression features speed development and resource usage isn’t a concern.
Practical suggestions to move forward
1. Continue with your tool-driven loop but standardize the pattern:
◦ Keep a single STT/TTS pipeline for the whole survey session.
◦ Use a single AskQuestion tool that you call repeatedly with different question parameters.
◦ Store answers as you go in session.userdata (or your session store).
1. Add checkpoints and resumability:
◦ Persist progress periodically so long surveys can resume if a session disconnects.
1. Monitor and ensure cleanup:
◦ Explicitly open the STT stream at survey start and close it at the end (or on error), rather than relying on per-question teardown.
1. If you need TaskGroup features (e.g., regression), consider a hybrid:
◦ Implement the main flow as a tool loop, and only use TaskGroup for sub-flows of a few related questions where regression is required.
1. If you want, I can help with:
◦ A minimal code sketch of a tool-driven loop pattern (AskQuestion tool + state handling).
◦ A checklist for opening/closing STT/TTS pipelines to avoid leaks.
◦ A hybrid design showing where TaskGroup could fit safely.
Would you like a short code sketch for the tool-driven loop (with session state and explicit STT handling) or a checklist for pipeline lifecycle management?
Sources: Tasks and task groups | LiveKit Documentation | Building multi-agent architectures with LiveKit agents | LiveKit, with interactive elements