Hey folks, I’ve got an Agent design question. I’m working on a survey agent asks about 30 questions. Is a Task Group the right primitive for this given the length of the survey?
I initially implemented the workflow as a task group with each question as a task (added in a for loop as a generic AskQuestion task with different parameters).
However, midway through the survey, agent started erroring out and I noticed that multiple STT streams were being created (roughly 2 for each task) and it seemed they weren’t being cleaned up. This made me uncertain whether TaskGroup was designed for long surveys.
I’ve temporarily worked around this by avoiding TaskGroup and instead using a tool-driven loop, but Im hoping to get guidance on what the right primitive for building 20+ question survey agents is. Thanks
Will try to dig up / recreate the original error message I was seeing as well and share it
Yes, TaskGroup would be the right approach for this and it’s designed for this kind of use case, did you see the survey example: agents/examples/survey at main · livekit/agents · GitHub ?
Thanks for the response here. I did see the example and tried it but was running into the STT stream error. Ultimately I decided to implement the questionnaire in a different way not using TaskGroup. Thanks for the support!
Glad you were able to resolve your issue. If you get a chance, it would be great if you could share reproduction steps for the ‘multiple STT streams’ issue based on that survey example. Or is it just a case of adding more questions (tasks) to that example?
Hi @Ubani_Balogun, thank you for your insight! +1 on getting a reproducible snippet with the STT provider. We support maintaining a single STT connection across tasks if the provider doesn’t change (source pr).
My hunch is that the logs may include the transition to TaskGroup between tasks. Two handoffs occur to get to the next AgentTask, which may explain why you see two connections created (though again the initial connection should be maintained)
Cc: @Ubani_Balogun,
@Tina_Nguyen’s two-handoffs-per-task explanation makes sense and would account for Ubani’s “~2 streams per task” observation cleanly: each AgentTask transition briefly stands up new STT connections during the handoff window, and the original should reattach if the provider is unchanged.
What distinguishes “expected brief 2x during handoff” from an actual leak is the steady-state count over time. If you instrument the FD count or netstat across the survey lifetime, a healthy run should spike by 2 around each transition and return to baseline. A leak would show the count growing monotonically with each task and never releasing.
Anyone hitting this in the future: that FD-over-time snapshot is the repro shape the team needs to triage further.