agents icon indicating copy to clipboard operation
agents copied to clipboard

fix: resolve audio dropout after AgentTask completion

Open tomc98 opened this issue 1 month ago • 2 comments

Fixed critical bugs causing agent to go silent after nested workflow agents (AgentTasks) complete:

  1. 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 None was False
    • Fix: Set audio_recognition, rt_session, and realtime_spans to None after closing them in _close_session()
  2. 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
  3. Transcript buffering during handover:

    • Buffer transcripts received during prestart mode
    • Replay them after complete_start() finishes
  4. 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

tomc98 avatar Dec 05 '25 06:12 tomc98