agents
agents copied to clipboard
fix: resolve audio dropout after AgentTask completion
Fixed critical bugs causing agent to go silent after nested workflow agents (AgentTasks) complete:
-
Audio recognition not recreated on resume:
- When activity is paused for AgentTask handover, _close_session() closed audio_recognition but didn't set it to None
- On resume, _start_session() skipped recreation because the check
if self._audio_recognition is Nonewas False - Fix: Set audio_recognition, rt_session, and realtime_spans to None after closing them in _close_session()
-
Atomic handover with prestart pattern:
- Added prestart() to create audio_recognition before activity swap
- Added complete_start() to finish startup after swap
- Reordered _update_activity() to prestart new activity before pausing old one, eliminating ~100-200ms audio gap
-
Transcript buffering during handover:
- Buffer transcripts received during prestart mode
- Replay them after complete_start() finishes
-
Additional race condition fixes:
- Fixed generation futures not marked done on interruption
- Fixed async generator cleanup race conditions
- Added auth_lock for authorization operations on SpeechHandle